diff options
author | hut <hut@lavabit.com> | 2009-07-20 04:54:47 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-07-20 04:54:47 +0200 |
commit | 381f3aee6bf7aec8c5336fcfbbd86b1b32affc8f (patch) | |
tree | 7ccc203b5b6cecc599daef02862d162434875865 | |
parent | 8dee61df3a8c767dd4960711e1b785b293bf5575 (diff) | |
download | ranger-381f3aee6bf7aec8c5336fcfbbd86b1b32affc8f.tar.gz |
little hack for cd-after-exit
if you want to change the directory to where you left ranger when you exit, you can now simply use this in your .bashrc: alias ranger='source ranger' or even: alias ranger='. ranger' the old way was: alias ranger='cd "`ranger --cd 3>&1 1>&2`"'
-rw-r--r-- | code/help.rb | 23 | ||||
-rwxr-xr-x | ranger.rb | 9 |
2 files changed, 19 insertions, 13 deletions
diff --git a/code/help.rb b/code/help.rb index 1726e484..41f4212d 100644 --- a/code/help.rb +++ b/code/help.rb @@ -236,24 +236,21 @@ module Fm 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`"' + To use this feature, you have to start ranger with: + . /path/to/ranger.rb - 2. reload your bashrc by typing: - source ~/.bashrc + The dot and space at the start is important! - 3. type in ranger, navigate and quit. in bash, you should still - be in the directory where you left with ranger. + of course you can create an alias in our ~/.bashrc + alias fm='. /path/to/ranger.rb' - 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. + I use fm (which means filemanager) because it's quick to type + and because fm was the working title of ranger in the early days. + + If you're inside ranger and decide to stay in the original directory + after all, you can type tc or quit with ZX diff --git a/ranger.rb b/ranger.rb index 2ee36465..cc95c619 100755 --- a/ranger.rb +++ b/ranger.rb @@ -1,4 +1,13 @@ #!/usr/bin/ruby -Ku +##-------------------------------------------------- +# Ignore the following lines + +if false; then +=begin +fi; cd "`ranger --cd $@ 3>&1 1>&2`"; return +=end +end + version = '0.2.4' require 'pathname' |