summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-06 03:47:12 +0200
committerhut <hut@lavabit.com>2010-04-06 03:47:12 +0200
commit6ff604ba8bb484f570d033378006035a7c8d0b51 (patch)
treeeb9c51f99932408a3e048e0ccf1f880ae9f998a2
parent6c47470535209ac48900d6db6b17ff1e0cd9e6be (diff)
downloadranger-6ff604ba8bb484f570d033378006035a7c8d0b51.tar.gz
commands: added ":quit!" and made ":quit" to "close a tab or quit"
This is more similar to the behaviour of vim.
-rw-r--r--ranger/defaults/commands.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index c7f5e917..b20c7178 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -240,11 +240,25 @@ class quit(Command):
 	"""
 	:quit
 
+	Closes the current tab.  If there is only one tab, quit the program.
+	"""
+
+	def execute(self):
+		if len(self.fm.tabs) <= 1:
+			self.fm.exit()
+		self.fm.tab_close()
+
+
+class quit_now(Command):
+	"""
+	:quit!
+
 	Quits the program immediately.
 	"""
+	name = 'quit!'
 
 	def execute(self):
-		raise SystemExit
+		self.fm.exit()
 
 
 class delete(Command):
@@ -499,5 +513,6 @@ def get_command(name, abbrev=True):
 def command_generator(start):
 	return (cmd + ' ' for cmd in by_name if cmd.startswith(start))
 
-alias(e=edit)  # to make :e unambiguous.
+alias(e=edit, q=quit)  # for unambiguity
+alias(**{'q!':quit_now})