From 6ff604ba8bb484f570d033378006035a7c8d0b51 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 6 Apr 2010 03:47:12 +0200 Subject: commands: added ":quit!" and made ":quit" to "close a tab or quit" This is more similar to the behaviour of vim. --- ranger/defaults/commands.py | 19 +++++++++++++++++-- 1 file 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}) -- cgit 1.4.1-2-gfad0