diff options
-rw-r--r-- | README | 9 | ||||
-rw-r--r-- | ranger/core/fm.py | 2 | ||||
-rw-r--r-- | ranger/core/helper.py | 3 | ||||
-rw-r--r-- | ranger/help/invocation.py | 4 |
4 files changed, 13 insertions, 5 deletions
diff --git a/README b/README index c1462ec3..cf0e3577 100644 --- a/README +++ b/README @@ -96,12 +96,11 @@ Combine Ranger With Other Applications Add this to your ~/.bashrc to use ranger as a directory switcher: function ranger-cd { - before="$(pwd)" - python2.6 /the/path/to/ranger/ranger.py --fail-unless-cd "$@" || return 0 - after="$(grep \^\' ~/.config/ranger/bookmarks | cut -b3-)" - if [[ "$before" != "$after" ]]; then - cd "$after" + ranger --choosedir=/tmp/chosen + if [ -f /tmp/chosen -a "$(cat /tmp/chosen)" != "$(pwd | tr -d "\n")" ]; then + cd "$(cat /tmp/chosen)" fi + rm -f /tmp/chosen } bind '"\C-o":"ranger-cd\C-m"' diff --git a/ranger/core/fm.py b/ranger/core/fm.py index 116717ca..ec2fbdbb 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -212,5 +212,7 @@ class FM(Actions, SignalDispatcher): raise SystemExit finally: + if ranger.arg.choosedir and self.env.cwd and self.env.cwd.path: + open(ranger.arg.choosedir, 'w').write(self.env.cwd.path) self.bookmarks.remember(env.cwd) self.bookmarks.save() diff --git a/ranger/core/helper.py b/ranger/core/helper.py index 249b4c5c..cb0afefe 100644 --- a/ranger/core/helper.py +++ b/ranger/core/helper.py @@ -69,6 +69,9 @@ def parse_arguments(): help="Makes ranger act like a file chooser. When opening " "a file, it will quit and write the name of the selected " "file to TARGET.") + parser.add_option('--choosedir', type='string', metavar='TARGET', + help="Makes ranger act like a directory chooser. When ranger quits" + ", it will write the name of the last visited directory to TARGET") options, positional = parser.parse_args() arg = OpenStruct(options.__dict__, targets=positional) diff --git a/ranger/help/invocation.py b/ranger/help/invocation.py index c4a06543..afb1cd27 100644 --- a/ranger/help/invocation.py +++ b/ranger/help/invocation.py @@ -70,6 +70,10 @@ command line. as <target>. This file can be read in a script and used to open a certain file which has been chosen with ranger. +--choosedir=<target> + Makes ranger act like a directory chooser. When ranger quits, it will + write the name of the last visited directory to <target> + (Optional) Positional Argument The positional argument should be a path to the directory you want ranger to start in, or the file which you want to run. |