summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.13
-rw-r--r--doc/ranger.pod4
-rw-r--r--ranger/core/helper.py2
-rw-r--r--ranger/core/main.py7
4 files changed, 16 insertions, 0 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index e9f00501..c1a5b381 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -178,6 +178,9 @@ selected files into \fItargetfile\fR, adding one newline after each filename.
 .IX Item "--choosedir=targetfile"
 Allows you to pick a directory with ranger.  When you exit ranger, it will
 write the last visited directory into \fItargetfile\fR.
+.IP "\fB\-\-selectfile\fR=\fItargetfile\fR" 14
+.IX Item "--selectfile=targetfile"
+Open ranger with \fItargetfile\fR selected.
 .IP "\fB\-\-copy\-config\fR=\fIfile\fR" 14
 .IX Item "--copy-config=file"
 Create copies of the default configuration files in your local configuration
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 069b9de1..8943b476 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -67,6 +67,10 @@ selected files into I<targetfile>, adding one newline after each filename.
 Allows you to pick a directory with ranger.  When you exit ranger, it will
 write the last visited directory into I<targetfile>.
 
+=item B<--selectfile>=I<targetfile>
+
+Open ranger with I<targetfile> selected.
+
 =item B<--copy-config>=I<file>
 
 Create copies of the default configuration files in your local configuration
diff --git a/ranger/core/helper.py b/ranger/core/helper.py
index c22a52b8..88072e13 100644
--- a/ranger/core/helper.py
+++ b/ranger/core/helper.py
@@ -66,6 +66,8 @@ def parse_arguments():
 			", it will write the name of the last visited directory to TARGET")
 	parser.add_option('--list-unused-keys', action='store_true',
 			help="List common keys which are not bound to any action.")
+	parser.add_option('--selectfile', type='string', metavar='filepath',
+			help="Open ranger with supplied file selected.")
 
 	options, positional = parser.parse_args()
 	arg = OpenStruct(options.__dict__, targets=positional)
diff --git a/ranger/core/main.py b/ranger/core/main.py
index c87a4660..14e4b1f6 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -49,6 +49,10 @@ def main():
 
 	SettingsAware._setup(clean=arg.clean)
 
+	if arg.selectfile:
+		arg.selectfile = os.path.abspath(arg.selectfile)
+		arg.targets.insert(0, os.path.dirname(arg.selectfile))
+
 	targets = arg.targets or ['.']
 	target = targets[0]
 	if arg.targets:
@@ -97,6 +101,9 @@ def main():
 			from ranger.ext import curses_interrupt_handler
 			curses_interrupt_handler.install_interrupt_handler()
 
+		if arg.selectfile:
+			fm.select_file(arg.selectfile)
+
 		# Run the file manager
 		fm.initialize()
 		fm.ui.initialize()