about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/api/commands.py19
-rw-r--r--ranger/core/actions.py2
-rw-r--r--ranger/gui/widgets/console.py2
3 files changed, 11 insertions, 12 deletions
diff --git a/ranger/api/commands.py b/ranger/api/commands.py
index b9e0d6e9..24a82d0b 100644
--- a/ranger/api/commands.py
+++ b/ranger/api/commands.py
@@ -51,12 +51,11 @@ class CommandContainer(FileManagerAware):
 
     def alias(self, name, full_command):
         cmd_name = full_command.split()[0]
-        try:
-            cmd = self.get_command(cmd_name)
-        except KeyError:
+        cmd_cls = self.get_command(cmd_name)
+        if cmd_cls is None:
             self.fm.notify('alias failed: No such command: {0}'.format(cmd_name), bad=True)
             return None
-        self.commands[name] = _command_init(command_alias_factory(name, cmd, full_command))
+        self.commands[name] = _command_init(command_alias_factory(name, cmd_cls, full_command))
 
     def load_commands_from_module(self, module):
         for var in vars(module).values():
@@ -74,7 +73,7 @@ class CommandContainer(FileManagerAware):
             if hasattr(attribute, '__call__'):
                 self.commands[attribute_name] = _command_init(command_function_factory(attribute))
 
-    def get_command(self, name, abbrev=True):
+    def get_command(self, name, abbrev=False):
         if abbrev:
             lst = [cls for cmd, cls in self.commands.items()
                    if cls.allow_abbrev and cmd.startswith(name) or cmd == name]
@@ -85,11 +84,11 @@ class CommandContainer(FileManagerAware):
             if self.commands[name] in lst:
                 return self.commands[name]
             raise ValueError("Ambiguous command")
-        else:
-            try:
-                return self.commands[name]
-            except KeyError:
-                return None
+
+        try:
+            return self.commands[name]
+        except KeyError:
+            return None
 
     def command_generator(self, start):
         return sorted(cmd + ' ' for cmd in self.commands if cmd.startswith(start))
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 8bb66a62..703577d3 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -222,7 +222,7 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
         Execute a command for the console
         """
         command_name = string.lstrip().split()[0]
-        cmd_class = self.commands.get_command(command_name, abbrev=False)
+        cmd_class = self.commands.get_command(command_name)
         if cmd_class is None:
             self.notify("Command not found: `%s'" % command_name, bad=True)
             return
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index b3fa7151..cc595230 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -450,7 +450,7 @@ class Console(Widget):  # pylint: disable=too-many-instance-attributes,too-many-
         return command_class(self.line)
 
     def get_cmd_class(self):
-        return self.fm.commands.get_command(self.line.split()[0])
+        return self.fm.commands.get_command(self.line.split()[0], abbrev=True)
 
     def _get_tab(self, tabnum):
         if ' ' in self.line: