about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-27 03:26:45 +0100
committerhut <hut@lavabit.com>2009-12-27 03:26:45 +0100
commitb5493fe4b4c47c6ea7834421c67416358f28d3c1 (patch)
treea669fa9132d21e2491832aa605de068c6cd8a87a /ranger
parent34266423a7bf6969a7df3faccc9c73db01c35d82 (diff)
downloadranger-b5493fe4b4c47c6ea7834421c67416358f28d3c1.tar.gz
action.spawn/runcmd for terminals and du | less
Diffstat (limited to 'ranger')
-rw-r--r--ranger/actions.py8
-rw-r--r--ranger/applications.py11
-rw-r--r--ranger/defaults/keys.py3
3 files changed, 17 insertions, 5 deletions
diff --git a/ranger/actions.py b/ranger/actions.py
index 31f4cb41..aa2cc311 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -192,10 +192,14 @@ class Actions(EnvironmentAware, SettingsAware):
 		if func is not None:
 			self.env.settings['sort'] = str(func)
 	
-	def spawn(self, command):
+	def spawn(self, cmd, suspend=False, wait=False):
 		from ranger.applications import spawn
-		spawn(command, fm=self)
+		spawn(cmd, fm=self, suspend=wait, wait=wait)
 	
+	def runcmd(self, cmd, suspend=True, wait=True):
+		from ranger.applications import spawn
+		spawn(cmd, fm=self, suspend=wait, wait=wait)
+
 	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 ed5f282e..ae1ca2e1 100644
--- a/ranger/applications.py
+++ b/ranger/applications.py
@@ -81,10 +81,15 @@ def spawn(command, fm=None, suspend=True, wait=True):
 		fm.ui.suspend()
 
 	try:
-		if fm and fm.stderr_to_out:
-			process = Popen(command, shell=True, stderr=STDOUT)
+		if wait:
+			kw = {}
 		else:
-			process = Popen(command, shell=True)
+			kw = {'stdout':null, 'stderr':null, 'stdin':null}
+
+		if fm and fm.stderr_to_out:
+			if 'stderr' not in kw:
+				kw['stderr'] = STDOUT
+		process = Popen(command, shell=True, **kw)
 		if wait:
 			waitpid_no_intr(process.pid)
 	finally:
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 88f570df..fcd6591e 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -82,6 +82,9 @@ def initialize_commands(command_list):
 	bind('cd', do('open_console', cmode.COMMAND, 'cd '))
 	bind('f', do('open_console', cmode.COMMAND_QUICK, 'find '))
 
+	bind('term', do('spawn', 'x-terminal-emulator'))
+	bind('du', do('runcmd', 'du --max-depth=1 -h | less'))
+
 	# key combinations which change the current directory
 	def cd(path):
 		return lambda fm: fm.enter_dir(path)