From 19bf3029b53b7d879f7d93d929b1e82449743ffe Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 21 Oct 2011 11:28:42 +0200 Subject: core.actions: added --choosefiles option + doc --- doc/ranger.1 | 9 +++++++-- doc/ranger.pod | 8 +++++++- ranger/core/actions.py | 6 ++++++ ranger/core/helper.py | 4 ++++ 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 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. +=item B<--choosefiles>=I + +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, adding one newline after each filename. + =item B<--choosedir>=I 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") -- cgit 1.4.1-2-gfad0