about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-17 21:15:00 +0100
committerhut <hut@lavabit.com>2009-12-17 21:15:00 +0100
commit5066893ab9e77e2f817b5182b87c0b5679c985ad (patch)
tree654badd07916b62a9ac7cd4178662013a61f6427
parent4700f3e5cb62355fe2baaa3b732f4dbdf52a5fc9 (diff)
downloadranger-5066893ab9e77e2f817b5182b87c0b5679c985ad.tar.gz
quit command, aliases
-rw-r--r--ranger/commands.py29
-rw-r--r--ranger/ext/debug.py4
2 files changed, 23 insertions, 10 deletions
diff --git a/ranger/commands.py b/ranger/commands.py
index a4ef2b22..14c47e30 100644
--- a/ranger/commands.py
+++ b/ranger/commands.py
@@ -44,10 +44,10 @@ class Command(FileManagerAware):
 
 class cd(Command):
 	"""The cd command changes the directory. The command 'cd -' is
-equivalent to typing ``. In the quick console, the directory
-will be entered without the need to press enter, as soon as there
-is one unambiguous match.
-"""
+	equivalent to typing ``. In the quick console, the directory
+	will be entered without the need to press enter, as soon as there
+	is one unambiguous match.
+	"""
 
 	def execute(self):
 		line = parse(self.line)
@@ -115,10 +115,10 @@ is one unambiguous match.
 
 class find(Command):
 	"""The find command will attempt to find a partial, case insensitive
-match in the filenames of the current directory. In the quick command
-console, once there is one unambiguous match, the file will be run
-automatically.
-"""
+	match in the filenames of the current directory. In the quick command
+	console, once there is one unambiguous match, the file will be run
+	automatically.
+	"""
 	count = 0
 	def execute(self):
 		if self.mode != '>':
@@ -159,6 +159,13 @@ automatically.
 
 		return self.count == 1
 
+
+class quit(Command):
+	"""Quits the program."""
+	def execute(self):
+		raise SystemExit
+
+
 # -------------------------------- rest
 
 by_name = {}
@@ -168,3 +175,9 @@ for varname, var in vars().copy().items():
 			by_name[var.name or varname] = var
 	except TypeError:
 		pass
+
+def alias(**kw):
+	for key, value in kw.items():
+		by_name[key] = value
+
+alias(q=quit)
diff --git a/ranger/ext/debug.py b/ranger/ext/debug.py
index 63a1cfd0..9a4dcbc0 100644
--- a/ranger/ext/debug.py
+++ b/ranger/ext/debug.py
@@ -2,13 +2,13 @@ LOGFILE = '/tmp/errorlog'
 
 def log(*objects, **keywords):
 	"""Writes objects to a logfile.
-Has the same arguments as print() in python3"""
+	Has the same arguments as print() in python3"""
 	start = 'start' in keywords and keywords['start'] or 'ranger:'
 	sep   =   'sep' in keywords and keywords['sep']   or ' '
 	_file =  'file' in keywords and keywords['file']  or open(LOGFILE, 'a')
 	end   =   'end' in keywords and keywords['end']   or '\n'
 	_file.write(sep.join(map(str, (start, ) + objects)) + end)
-	
+
 #for python3-only versions, this could be replaced with:
 #
 #def log(*objects, start='ranger:', sep=' ', end='\n'):