about summary refs log tree commit diff stats
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
parent34266423a7bf6969a7df3faccc9c73db01c35d82 (diff)
downloadranger-b5493fe4b4c47c6ea7834421c67416358f28d3c1.tar.gz
action.spawn/runcmd for terminals and du | less
-rw-r--r--TODO12
-rw-r--r--ranger/actions.py8
-rw-r--r--ranger/applications.py11
-rw-r--r--ranger/defaults/keys.py3
4 files changed, 22 insertions, 12 deletions
diff --git a/TODO b/TODO
index b1bad60a..87da0de8 100644
--- a/TODO
+++ b/TODO
@@ -2,7 +2,7 @@ Console
 
    (X) #0   09/12/06  console commands
    (X) #1   09/12/06  quick find
-   ( ) #2   09/12/06  open with
+   (X) #2   09/12/06  open with
    ( ) #3   09/12/06  MVC for widgets
    (X) #4   09/12/06  history for console
 
@@ -12,10 +12,8 @@ General
    (X) #5   09/12/06  move code from fm into objects
    (X) #6   09/12/06  move main to __init__
    (X) #7   09/12/06  cooler titlebar
-   ( ) #9   09/12/24  add a widget for managing running operations
-   (X) #10  09/12/24  sorting
-
-
-Filesystem Modification Operations
-
    (X) #8   09/12/17  Add operations to modify files/directories
+   (X) #9   09/12/24  add a widget for managing running operations
+   (X) #10  09/12/24  sorting
+   ( ) #11  09/12/27  filter
+   ( ) #12  09/12/27  jump through the list in a specific order
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)