diff options
author | David Pugnasse <david.pugnasse@gmail.com> | 2011-10-24 00:58:33 +0200 |
---|---|---|
committer | David Pugnasse <david.pugnasse@gmail.com> | 2011-10-24 00:58:33 +0200 |
commit | 8a2d5352480629aeb7a983ea4ddadf7005223907 (patch) | |
tree | 4e9ccac02a816a8cab335f8c1b1d86924676865c /ranger | |
parent | 989013dcb7fcd9ff5d03608283acd8da27ca3238 (diff) | |
download | ranger-8a2d5352480629aeb7a983ea4ddadf7005223907.tar.gz |
core.main: added --selectfile option
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/core/actions.py | 8 | ||||
-rw-r--r-- | ranger/core/helper.py | 2 | ||||
-rw-r--r-- | ranger/core/main.py | 6 |
3 files changed, 14 insertions, 2 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 5364f391..3300a534 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -344,8 +344,12 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): def select_file(self, path): path = path.strip() - if self.enter_dir(os.path.dirname(path)): - self.env.cwd.move_to_obj(path) + dirname = os.path.dirname(path) + if dirname: + if self.enter_dir(dirname): + self.env.cwd.move_to_obj(path) + else: + self.env.cwd.move_to_obj(join(self.env.cwd.path, path)) def history_go(self, relative): """Move back and forth in the history""" 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..49513125 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -49,6 +49,9 @@ def main(): SettingsAware._setup(clean=arg.clean) + if arg.selectfile: + arg.targets.insert(0, os.path.dirname(arg.selectfile)) + targets = arg.targets or ['.'] target = targets[0] if arg.targets: @@ -97,6 +100,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() |