diff options
author | joe <joebodo@gmail.com> | 2012-04-13 14:30:20 -0400 |
---|---|---|
committer | hut <hut@lavabit.com> | 2012-06-07 01:45:38 +0200 |
commit | 20f386e57398a16146a6e58f2b6ba349ed9248dd (patch) | |
tree | 9e2f8b541370a5b2e54442951eb5f1ac76969de1 /ranger | |
parent | f893d2feb5daa44ea7f0f1fdddcedc789d82644c (diff) | |
download | ranger-20f386e57398a16146a6e58f2b6ba349ed9248dd.tar.gz |
Extended aliases
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/api/commands.py | 18 | ||||
-rw-r--r-- | ranger/defaults/commands.py | 6 |
2 files changed, 21 insertions, 3 deletions
diff --git a/ranger/api/commands.py b/ranger/api/commands.py index c3317939..97ef415c 100644 --- a/ranger/api/commands.py +++ b/ranger/api/commands.py @@ -23,9 +23,15 @@ class CommandContainer(object): def __getitem__(self, key): return self.commands[key] - def alias(self, new, old): + def alias(self, name, full_command): try: - self.commands[new] = self.commands[old] + cmd = type(name, (AliasCommand, ), dict()) + cmd._based_function = name + cmd._function_name = name + cmd._object_name = name + cmd._line = full_command + self.commands[name] = cmd + except: pass @@ -317,3 +323,11 @@ class FunctionCommand(Command): self.fm.notify("Bad arguments for %s.%s: %s, %s" % (self._object_name, self._function_name, repr(args), repr(keywords)), bad=True) + +class AliasCommand(Command): + _based_function = None + _object_name = "" + _function_name = "unknown" + _line = "" + def execute(self): + self.fm.execute_console(self._line) diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py index 52a1d30e..db411436 100644 --- a/ranger/defaults/commands.py +++ b/ranger/defaults/commands.py @@ -86,11 +86,15 @@ class alias(Command): Copies the oldcommand as newcommand. """ + + context = 'browser' + resolve_macros = False + def execute(self): if not self.arg(1) or not self.arg(2): self.fm.notify('Syntax: alias <newcommand> <oldcommand>', bad=True) else: - self.fm.commands.alias(self.arg(1), self.arg(2)) + self.fm.commands.alias(self.arg(1), self.rest(2)) class cd(Command): """ |