diff options
-rw-r--r-- | ranger/actions.py | 11 | ||||
-rw-r--r-- | ranger/commands.py | 6 | ||||
-rw-r--r-- | ranger/defaults/keys.py | 7 |
3 files changed, 24 insertions, 0 deletions
diff --git a/ranger/actions.py b/ranger/actions.py index d500f18a..31f4cb41 100644 --- a/ranger/actions.py +++ b/ranger/actions.py @@ -283,6 +283,17 @@ class Actions(EnvironmentAware, SettingsAware): os.mkdir(os.path.join(self.env.pwd.path, name)) except OSError as err: self.notify(str(err), bad=True) + + + def rename(self, src, dest): + if hasattr(src, 'path'): + src = src.path + + try: + os.rename(src, dest) + except OSError as err: + self.notify(str(err), bad=True) + def notify(self, text, duration=4, bad=False): try: diff --git a/ranger/commands.py b/ranger/commands.py index a3cc131e..68b9c574 100644 --- a/ranger/commands.py +++ b/ranger/commands.py @@ -161,6 +161,12 @@ class mkdir(Command): pass +class rename(Command): + def execute(self): + line = parse(self.line) + self.fm.rename(self.fm.env.cf, line.rest(1)) + + # -------------------------------- rest by_name = {} diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 9837d2a2..88f570df 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -72,6 +72,13 @@ def initialize_commands(command_list): fm.sort(reverse=not fm.settings.reverse)) command_list.hint(sort_hint, 'o', 'O') + def edit_name(fm, n): + cf = fm.env.cf + if cf: + fm.open_console(cmode.COMMAND, 'rename ' + cf.basename) + + bind('A', edit_name) + bind('cw', do('open_console', cmode.COMMAND, 'rename ')) bind('cd', do('open_console', cmode.COMMAND, 'cd ')) bind('f', do('open_console', cmode.COMMAND_QUICK, 'find ')) |