diff options
author | hut <hut@lavabit.com> | 2009-12-27 00:54:20 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-12-27 00:54:20 +0100 |
commit | 582c9ff2c211a5dcf7ff9f042dbec791541d34b6 (patch) | |
tree | d149171ee012fcf5f58ac604c4c40ebe7e30fa42 | |
parent | 2efce5400bed218ca603444d179bee503fa6d9f5 (diff) | |
download | ranger-582c9ff2c211a5dcf7ff9f042dbec791541d34b6.tar.gz |
generalized tab completion code of cd command
-rw-r--r-- | ranger/commands.py | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/ranger/commands.py b/ranger/commands.py index 68b9c574..2c0593a3 100644 --- a/ranger/commands.py +++ b/ranger/commands.py @@ -19,29 +19,7 @@ class Command(FileManagerAware): def quick_open(self): """Override this""" -# -------------------------------- definitions - -class cd(Command): - """ - The cd command changes the directory. The command 'cd -' is - equivalent to typing ``. In the quick console, the directory - will be entered without the need to press enter, as soon as there - is one unambiguous match. - """ - - def execute(self): - line = parse(self.line) - try: - destination = line.rest(1) - except IndexError: - destination = '~' - - if destination == '-': - self.fm.enter_bookmark('`') - else: - self.fm.enter_dir(destination) - - def tab(self): + def _tab_through_directories(self): from os.path import dirname, basename, expanduser, join, isdir line = parse(self.line) @@ -79,6 +57,31 @@ class cd(Command): return line + join(rel_dirname, dirnames[0]) + '/' return (line + join(rel_dirname, dirname) for dirname in dirnames) + +# -------------------------------- definitions + +class cd(Command): + """ + The cd command changes the directory. The command 'cd -' is + equivalent to typing ``. In the quick console, the directory + will be entered without the need to press enter, as soon as there + is one unambiguous match. + """ + + def execute(self): + line = parse(self.line) + try: + destination = line.rest(1) + except IndexError: + destination = '~' + + if destination == '-': + self.fm.enter_bookmark('`') + else: + self.fm.enter_dir(destination) + + def tab(self): + return self._tab_through_directories() def quick_open(self): from os.path import isdir, join, normpath |