ranger-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ranger-users] Ranger tip: Save tabs


From: Roman Z.
Subject: Re: [Ranger-users] Ranger tip: Save tabs
Date: Wed, 30 Jun 2010 21:25:15 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

On Mon, Jun 28, 2010 at 07:25:04PM +0200, Jostein Berntsen wrote:
> Here is a tip if you want to save a config for tabs in ranger that you 
> can open while the application is running. Save a set of directories in 
> a bash script file like:
> 
> #!/bin/sh
> 
> /home/jostein/dw/ranger/ranger.py ~/Pictures ~/Documents ~/Documents/tips 
> ~/mp3 ~/Documents/Finans 
> 
> Then you can bind this script to a key in keys.py. The script is called 
> "ry":
> 
> map('_t', fm.open_console(cmode.OPEN, '!source ry'))
> 
> 
> You can then make several scripts like this for different keys. Maybe a 
> hack, but it works great for me. This needs the latest version of ranger 
> that can open several directories from the command line.
> 
> 
> Jostein
> 

You can also map a key to a function like this:

def exit_and_save_tabs(arg):
        open('/home/myname/bin/ranger', 'w').write("#!/bin/sh\nexec 
/usr/bin/ranger " + " ".join(arg.fm.tabs.values()))
        arg.fm.exit()

map("Q", exit_and_save_tabs)


Whenever you quit ranger with Q, tabs will be saved :-)
Now run ranger with ~/bin/ranger.
Spaces in directories may still need special treatment, with
ranger.ext.shell_escape.shell_quote() perhaps:

def exit_and_save_tabs(arg):
        from ranger.ext.shell_escape import shell_quote
        open('/home/myname/bin/ranger', 'w').write("#!/bin/sh\nexec 
/usr/bin/ranger " + " ".join(shell_quote(f) for f in arg.fm.tabs.values()))
        arg.fm.exit()


(nothing tested)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]