diff options
Diffstat (limited to 'code')
-rw-r--r-- | code/extensions/basic.rb | 8 | ||||
-rw-r--r-- | code/fm.rb | 7 | ||||
-rw-r--r-- | code/help.rb | 25 | ||||
-rw-r--r-- | code/keys.rb | 14 |
4 files changed, 47 insertions, 7 deletions
diff --git a/code/extensions/basic.rb b/code/extensions/basic.rb index 1e890a04..dd2f0fd0 100644 --- a/code/extensions/basic.rb +++ b/code/extensions/basic.rb @@ -75,9 +75,13 @@ class String ## peter's song.mp3 -> 'peter'\''s song.mp3' ## ## system("mplayer #{ ~some_video_file }") - def ~ - "'#{ gsub("'", "'\\\\''") }'" + def bash_escape + "'#{bash_escape_no_quotes}'" end + def bash_escape_no_quotes + "#{ gsub("'", "'\\\\''") }" + end + alias ~ bash_escape end class Numeric diff --git a/code/fm.rb b/code/fm.rb index ba33279a..0f2893b3 100644 --- a/code/fm.rb +++ b/code/fm.rb @@ -84,6 +84,13 @@ module Fm $VERBOSE = old_verbose_level end + def dump_pwd_to_3() + f = File.open(3, 'a') + f.puts(Fm.pwd.path) +# f.puts(Fm.pwd.path.bash_escape) + f.close + end + def boot_up(pwd=nil) pwd ||= @pwd.path || Dir.getwd Scheduler.reset diff --git a/code/help.rb b/code/help.rb index 77d93e1d..974039b7 100644 --- a/code/help.rb +++ b/code/help.rb @@ -14,6 +14,7 @@ module Fm l running files in different ways c creating, deleting, moving, copying o more commands that don't fit elsewhere + z switching to the PWD after exiting ranger To interrupt current operations: <Ctrl-C> To quit: Q or ZZ or <Ctrl-D> or <Ctrl-C><Ctrl-C> (quickly twice in a row) @@ -210,6 +211,30 @@ module Fm + key:z + One possible use of ranger is navigating quickly to a directory, + exit ranger, return to the shell but stay at the location where you + left with ranger. + To use this feature, do the following: + + 1. enter this line into your ~/.bashrc (if you use bash. other + shells should be similar): + alias ranger='cd "`/path/to/ranger --cd 3>&1 1>&2`"' + + 2. reload your bashrc by typing: + source ~/.bashrc + + 3. type in ranger, navigate and quit. in bash, you should still + be in the directory where you left with ranger. + + The --cd switch writes the pwd to the 3rd file descriptor on exit, + the cd command will read from it and change the dir accordingly. + If you decide that you don't want to change the directory after all, + you can toggle the --cd switch inside ranger by typing tc. + Also, typing ZX quits ranger with the --cd switch inverted. + + + END hash = {} diff --git a/code/keys.rb b/code/keys.rb index b652ff92..d4021ff2 100644 --- a/code/keys.rb +++ b/code/keys.rb @@ -3,7 +3,7 @@ module Fm # or regexps which match combinations need to be in here! COMBS = %w( g d df y c Z delet cu - ter ta S ?? ?g ?f ?m ?l ?c ?o :q + ter ta S ?? ?g ?f ?m ?l ?c ?o ?z o m ` ' go um @@ -178,11 +178,8 @@ module Fm @bars.first.kill unless @bars.empty? when 'X' -# @bars.last.kill unless @bars.empty? + @bars.last.kill unless @bars.empty? - closei - exec(ENV['SHELL']) - exit when 'J' @pwd.pos += lines/2 @@ -391,6 +388,9 @@ module Fm Option.show_hidden ^= true @pwd.refresh! + when 'tc' + Option.cd ^= true + when 'td' Option.dir_first ^= true @pwd.schedule @@ -579,6 +579,10 @@ module Fm when 'ZZ', '<c-d>', ':q<cr>', 'Q' exit + when 'ZX' + Option.cd ^= true + exit + when '<c-r>' Fm.boot_up |