about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-10-21 11:28:42 +0200
committerhut <hut@lavabit.com>2011-10-21 11:28:42 +0200
commit19bf3029b53b7d879f7d93d929b1e82449743ffe (patch)
tree49b44d0d969f2086b7f359e4381f2158f9644fbe
parent5f67653b6ae232f7475049136421df0d016d283c (diff)
downloadranger-19bf3029b53b7d879f7d93d929b1e82449743ffe.tar.gz
core.actions: added --choosefiles option + doc
-rw-r--r--doc/ranger.19
-rw-r--r--doc/ranger.pod8
-rw-r--r--ranger/core/actions.py6
-rw-r--r--ranger/core/helper.py4
4 files changed, 24 insertions, 3 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index da98f718..58d51050 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -124,7 +124,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.5.0" "10/11/2011" "ranger manual"
+.TH RANGER 1 "ranger-1.5.0" "10/21/2011" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -167,8 +167,13 @@ configuration is broken, when you want to avoid clutter, etc.
 .IP "\fB\-\-choosefile\fR=\fItargetfile\fR" 14
 .IX Item "--choosefile=targetfile"
 Allows you to pick a file with ranger.  This changes the behavior so that when
-you open a file, ranger will exit and write the name of that file into
+you open a file, ranger will exit and write the absolute path of that file into
 \&\fItargetfile\fR.
+.IP "\fB\-\-choosefiles\fR=\fItargetfile\fR" 14
+.IX Item "--choosefiles=targetfile"
+Allows you to pick multiple files with ranger.  This changes the behavior so
+that when you open a file, ranger will exit and write the absolute paths of all
+selected files into \fItargetfile\fR, adding one newline after each filename.
 .IP "\fB\-\-choosedir\fR=\fItargetfile\fR" 14
 .IX Item "--choosedir=targetfile"
 Allows you to pick a directory with ranger.  When you exit ranger, it will
diff --git a/doc/ranger.pod b/doc/ranger.pod
index ec272de1..069b9de1 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -53,9 +53,15 @@ configuration is broken, when you want to avoid clutter, etc.
 =item B<--choosefile>=I<targetfile>
 
 Allows you to pick a file with ranger.  This changes the behavior so that when
-you open a file, ranger will exit and write the name of that file into
+you open a file, ranger will exit and write the absolute path of that file into
 I<targetfile>.
 
+=item B<--choosefiles>=I<targetfile>
+
+Allows you to pick multiple files with ranger.  This changes the behavior so
+that when you open a file, ranger will exit and write the absolute paths of all
+selected files into I<targetfile>, adding one newline after each filename.
+
 =item B<--choosedir>=I<targetfile>
 
 Allows you to pick a directory with ranger.  When you exit ranger, it will
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 20b910da..0fd60b9a 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -249,6 +249,12 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 		# ranger can act as a file chooser when running with --choosefile=...
 		if ranger.arg.choosefile:
 			open(ranger.arg.choosefile, 'w').write(self.fm.env.cf.path)
+
+		if ranger.arg.choosefiles:
+			open(ranger.arg.choosefiles, 'w').write("".join(
+				f.path + "\n" for f in self.fm.env.get_selection()))
+
+		if ranger.arg.choosefile or ranger.arg.choosefiles:
 			raise SystemExit()
 
 		if isinstance(files, set):
diff --git a/ranger/core/helper.py b/ranger/core/helper.py
index 995be7c5..46d35f7a 100644
--- a/ranger/core/helper.py
+++ b/ranger/core/helper.py
@@ -56,6 +56,10 @@ 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('--choosefiles', type='string', metavar='TARGET',
+			help="Makes ranger act like a file chooser for multiple files "
+			"at once. When opening a file, it will quit and write the name "
+			"of all selected files 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")