summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-02-15 01:03:59 +0000
committerhut <hut@lavabit.com>2011-02-15 01:03:59 +0000
commitd008817c6d3ea828e12bed2c271c9ae36f80cbda (patch)
tree49e62d666d8f7432d1769e757baca051891505ea /ranger
parent9a2ec2b421e87e815806b4a7ae7452fb84f2027e (diff)
downloadranger-d008817c6d3ea828e12bed2c271c9ae36f80cbda.tar.gz
Added --choosedir, a more logical alternative to --fail-unless-cd
also updated the bash script in README to use the new option
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/fm.py2
-rw-r--r--ranger/core/helper.py3
-rw-r--r--ranger/help/invocation.py4
3 files changed, 9 insertions, 0 deletions
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.