diff options
author | hut <hut@lavabit.com> | 2009-12-25 21:59:51 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-12-25 21:59:51 +0100 |
commit | 5c210a96a0e4bb74cd096edb045fc3814b78450c (patch) | |
tree | 511c54091badbc91c71a7d76759d642648c9ce82 /ranger | |
parent | e7f81766920a47bf4b126108a25ce92885682bc2 (diff) | |
download | ranger-5c210a96a0e4bb74cd096edb045fc3814b78450c.tar.gz |
random updates
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/__init__.py | 6 | ||||
-rw-r--r-- | ranger/actions.py | 4 | ||||
-rw-r--r-- | ranger/applications.py | 18 | ||||
-rw-r--r-- | ranger/defaults/keys.py | 2 | ||||
-rw-r--r-- | ranger/fm.py | 1 |
5 files changed, 28 insertions, 3 deletions
diff --git a/ranger/__init__.py b/ranger/__init__.py index b934d80c..5eaaee4f 100644 --- a/ranger/__init__.py +++ b/ranger/__init__.py @@ -56,10 +56,9 @@ def main(): args, rest = parser.parse_args() + log(sys.argv) if args.cd_after_exit: sys.stderr = sys.__stdout__ - if rest[0] == sys.argv[0]: - del rest[0] # Initialize objects target = ' '.join(rest) @@ -81,7 +80,8 @@ def main(): try: my_ui = UI() - my_fm = FM(ui = my_ui) + my_fm = FM(ui=my_ui) + my_fm.stderr_to_out = args.cd_after_exit # Run the file manager my_fm.initialize() diff --git a/ranger/actions.py b/ranger/actions.py index a43d366f..b9ec2204 100644 --- a/ranger/actions.py +++ b/ranger/actions.py @@ -164,6 +164,10 @@ class Actions(EnvironmentAware, SettingsAware): if func is not None: self.env.settings['sort'] = str(func) + def spawn(self, command): + from ranger.applications import spawn + spawn(command, fm=self) + def force_load_preview(self): cf = self.env.cf if cf is not None: diff --git a/ranger/applications.py b/ranger/applications.py index a046a839..c9f2ec18 100644 --- a/ranger/applications.py +++ b/ranger/applications.py @@ -60,3 +60,21 @@ def run(*args, **kw): waitpid_no_intr(p.pid) if fm.ui: fm.ui.initialize() return p + +def spawn(command, fm=None, suspend=True, wait=True): + from subprocess import Popen, STDOUT + from ranger.ext.waitpid_no_intr import waitpid_no_intr + + if suspend and fm and fm.ui: + fm.ui.suspend() + + try: + if fm and fm.stderr_to_out: + process = Popen(command, shell=True, stderr=STDOUT) + else: + process = Popen(command, shell=True) + if wait: + waitpid_no_intr(process.pid) + finally: + if suspend and fm and fm.ui: + fm.ui.initialize() diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 683214f7..9fbc5b96 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -42,6 +42,8 @@ def initialize_commands(command_list): bind('cut', do('cut')) bind('p', do('paste')) + bind('s', do('spawn', 'bash')) + t_hint = "show_//h//idden //p//review_files //d//irectories_first //a//uto_load_preview //c//ollapse_preview" command_list.hint(t_hint, 't') bind('th', do('toggle_boolean_option', 'show_hidden')) diff --git a/ranger/fm.py b/ranger/fm.py index a1b1339a..a68c0f15 100644 --- a/ranger/fm.py +++ b/ranger/fm.py @@ -12,6 +12,7 @@ TICKS_BEFORE_COLLECTING_GARBAGE = 100 class FM(Actions): input_blocked = False input_blocked_until = 0 + stderr_to_out = False def __init__(self, ui = None, bookmarks = None): """Initialize FM.""" Actions.__init__(self) |