diff options
Diffstat (limited to 'ranger/gui/widgets/console.py')
-rw-r--r-- | ranger/gui/widgets/console.py | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index 1ee7ebc0..f02a4b01 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -44,7 +44,7 @@ OPEN_HISTORY = 3 class _CustomTemplate(string.Template): """A string.Template subclass for use in the OpenConsole""" delimiter = '%' - idpattern = '[a-z]' + idpattern = '\d?[a-z]' class Console(Widget): @@ -489,6 +489,40 @@ class OpenConsole(ConsoleWithTab): else: macros['d'] = '.' + # define d/f/s macros for each tab + for i in range(1,10): + try: + tab_dir_path = self.fm.tabs[i] + except: + continue + tab_dir = self.fm.env.get_directory(tab_dir_path) + i = str(i) + macros[i + 'd'] = shell_quote(tab_dir_path) + macros[i + 'f'] = shell_quote(tab_dir.pointed_obj.path) + macros[i + 's'] = ' '.join(shell_quote(fl.path) + for fl in tab_dir.get_selection()) + + # define D/F/S for the next tab + found_current_tab = False + next_tab_path = None + first_tab = None + for tab in self.fm.tabs: + if not first_tab: + first_tab = tab + if found_current_tab: + next_tab_path = self.fm.tabs[tab] + break + if self.fm.current_tab == tab: + found_current_tab = True + if found_current_tab and not next_tab_path: + next_tab_path = self.fm.tabs[first_tab] + next_tab = self.fm.env.get_directory(next_tab_path) + + macros['D'] = shell_quote(next_tab) + macros['F'] = shell_quote(next_tab.pointed_obj.path) + macros['S'] = ' '.join(shell_quote(fl.path) + for fl in next_tab.get_selection()) + return _CustomTemplate(command).safe_substitute(macros) def _parse(self): |