summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/runner.py19
-rw-r--r--ranger/help/starting.py1
2 files changed, 19 insertions, 1 deletions
diff --git a/ranger/core/runner.py b/ranger/core/runner.py
index 26424881..f35f99b7 100644
--- a/ranger/core/runner.py
+++ b/ranger/core/runner.py
@@ -37,10 +37,21 @@ from subprocess import Popen, PIPE
 from ranger.ext.waitpid_no_intr import waitpid_no_intr
 
 
-ALLOWED_FLAGS = 'sdpSDP'
+ALLOWED_FLAGS = 'sdpwSDPW'
 devnull = open(os.devnull, 'a')
 
 
+def press_enter():
+	"""Wait for an ENTER-press"""
+	sys.stdout.write("Press ENTER to continue")
+	try:
+		waitfnc = raw_input
+	except NameError:
+		# "raw_input" not available in python3
+		waitfnc = input
+	waitfnc()
+
+
 class Context(object):
 	"""
 	A context object contains data on how to run a process.
@@ -144,6 +155,7 @@ class Runner(object):
 
 		toggle_ui = True
 		pipe_output = False
+		wait_for_enter = False
 
 		popen_kws['args'] = action
 		if 'shell' not in popen_kws:
@@ -168,6 +180,9 @@ class Runner(object):
 		if 'd' in context.flags:
 			toggle_ui = False
 			context.wait = False
+		if 'w' in context.flags:
+			if not pipe_output and context.wait: # <-- sanity check
+				wait_for_enter = True
 
 		# Finally, run it
 
@@ -182,6 +197,8 @@ class Runner(object):
 			else:
 				if context.wait:
 					waitpid_no_intr(process.pid)
+				if wait_for_enter:
+					press_enter()
 		finally:
 			if toggle_ui:
 				self._activate_ui(True)
diff --git a/ranger/help/starting.py b/ranger/help/starting.py
index 069d6a04..99cfc45e 100644
--- a/ranger/help/starting.py
+++ b/ranger/help/starting.py
@@ -95,6 +95,7 @@ Flags give you a way to modify the behaviour of the spawned process.
 	s	Silent mode.  Output will be discarded.
 	d	Detach the process.  (Run in background)
 	p	Redirect output to the pager
+	w	Wait for an enter-press when the process is done
 
 For example, "open with: p" will pipe the output of that process into
 the pager.