diff options
author | nfnty <git@nfnty.se> | 2017-02-09 00:15:26 +0100 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-02-09 00:16:53 +0100 |
commit | a3ccb616e6fc8c88cf7ffcd079dab76655bcc002 (patch) | |
tree | be96caa70553f6137bb3831a6105cfa6d93dd49c /ranger | |
parent | c377b4814a5560a6fc34c5e5a5df2fe39d289cad (diff) | |
download | ranger-a3ccb616e6fc8c88cf7ffcd079dab76655bcc002.tar.gz |
commands: Add `quitall!`, Change behavior of `quit!`
Fixes #802
Diffstat (limited to 'ranger')
-rwxr-xr-x | ranger/config/commands.py | 37 | ||||
-rw-r--r-- | ranger/config/rc.conf | 14 |
2 files changed, 37 insertions, 14 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 012cbbde..8f71b241 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -477,9 +477,9 @@ class default_linemode(Command): class quit(Command): # pylint: disable=redefined-builtin """:quit - Closes the current tab. If there is only one tab, quit the program. + Closes the current tab, if there's only one tab. + Otherwise quits if there are no tasks in progress. """ - def _exit_no_work(self): if self.fm.loader.has_work(): self.fm.notify('Not quitting: Tasks in progress: Use `quit!` to force quit') @@ -493,22 +493,43 @@ class quit(Command): # pylint: disable=redefined-builtin self._exit_no_work() -class quitall(quit): +class quit_bang(Command): + """:quit! + + Closes the current tab, if there's only one tab. + Otherwise force quits immediately. + """ + name = 'quit!' + allow_abbrev = False + + def execute(self): + if len(self.fm.tabs) >= 2: + self.fm.tab_close() + else: + self.fm.exit() + + +class quitall(Command): """:quitall - Quits the program immediately. + Quits if there are no tasks in progress. """ + def _exit_no_work(self): + if self.fm.loader.has_work(): + self.fm.notify('Not quitting: Tasks in progress: Use `quitall!` to force quit') + else: + self.fm.exit() def execute(self): self._exit_no_work() -class quit_bang(Command): - """:quit! +class quitall_bang(Command): + """:quitall! - Quits the program immediately. + Force quits immediately. """ - name = 'quit!' + name = 'quitall!' allow_abbrev = False def execute(self): diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 0f60c195..5b301b3c 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -231,12 +231,14 @@ set wrap_scroll false # == Command Aliases in the Console # =================================================================== -alias e edit -alias q quit -alias q! quit! -alias qa quitall -alias qall quitall -alias setl setlocal +alias e edit +alias q quit +alias q! quit! +alias qa quitall +alias qa! quitall! +alias qall quitall +alias qall! quitall! +alias setl setlocal alias filter scout -prt alias find scout -aeit |