about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2013-02-05 04:08:38 +0100
committerhut <hut@lavabit.com>2013-02-05 04:08:38 +0100
commit5036975750fb3447f5a060bf1523773eb25d3313 (patch)
treedd273ecd9df97792defd5d118c5dde99b6a7124f
parentaa6cc7a69c5eb9300f9f9ce31a04998be1dab0f1 (diff)
downloadranger-5036975750fb3447f5a060bf1523773eb25d3313.tar.gz
added tab completion for open_with
-rw-r--r--ranger/api/commands.py11
-rw-r--r--ranger/config/commands.py3
2 files changed, 14 insertions, 0 deletions
diff --git a/ranger/api/commands.py b/ranger/api/commands.py
index 8e7e16ac..4a9688a0 100644
--- a/ranger/api/commands.py
+++ b/ranger/api/commands.py
@@ -271,6 +271,17 @@ class Command(FileManagerAware):
 			# manually type in the slash to advance into that directory
 			return (self.start(1) + join(rel_dirname, name) for name in names)
 
+	def _tab_through_executables(self):
+		from ranger.ext.get_executables import get_executables
+		programs = [program for program in get_executables() if \
+				program.startswith(self.rest(1))]
+		if not programs:
+			return
+		if len(programs) == 1:
+			return self.start(1) + programs[0]
+		programs.sort()
+		return (self.start(1) + program for program in programs)
+
 
 class FunctionCommand(Command):
 	_based_function = None
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index bc6e674c..74d306e8 100644
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -243,6 +243,9 @@ class open_with(Command):
 				flags = flags,
 				mode = mode)
 
+	def tab(self):
+		return self._tab_through_executables()
+
 	def _get_app_flags_mode(self, string):
 		"""
 		Extracts the application, flags and mode from a string.