summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/api/commands.py18
-rw-r--r--ranger/defaults/commands.py6
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):
 	"""