smart "S" to prevent nested shells
This commit is contained in:
@@ -60,3 +60,20 @@ class my_edit(Command):
|
||||
# This is a generic tab-completion function that iterates through the
|
||||
# content of the current directory.
|
||||
return self._tab_directory_content()
|
||||
|
||||
|
||||
class smart_shell(Command):
|
||||
""":smart_shell
|
||||
|
||||
If SHLVL == 1, spawn a new shell in the current directory.
|
||||
If SHLVL > 1, quit ranger (same as pressing 'q').
|
||||
"""
|
||||
|
||||
def execute(self):
|
||||
shlvl = int(os.environ.get('SHLVL', 1))
|
||||
if shlvl > 1:
|
||||
# We're in a nested shell, quit ranger to return to parent shell
|
||||
self.fm.execute_console('quit')
|
||||
else:
|
||||
# Top-level shell, spawn a new shell
|
||||
self.fm.execute_command(os.environ.get('SHELL', '/bin/sh'))
|
||||
|
||||
@@ -347,7 +347,7 @@ map i display_file
|
||||
map ? help
|
||||
map W display_log
|
||||
map w taskview_open
|
||||
map S shell $SHELL
|
||||
map S smart_shell
|
||||
|
||||
map : console
|
||||
map ; console
|
||||
|
||||
@@ -164,6 +164,7 @@ ext pdf, has qpdfview, X, flag f = qpdfview "$@"
|
||||
ext pdf, has open, X, flag f = open "$@"
|
||||
mime application/pdf, has zathura, X, flag f = zathura -- "$@"
|
||||
|
||||
ext docx, has libreoffice, X, flag f = libreoffice "$@"
|
||||
ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
|
||||
|
||||
ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric, X, flag f = gnumeric -- "$@"
|
||||
|
||||
@@ -84,7 +84,7 @@ handle_extension() {
|
||||
## Preview as text conversion
|
||||
odt2txt "${FILE_PATH}" && exit 5
|
||||
## Preview as markdown conversion
|
||||
pandoc -s -t markdown -- "${FILE_PATH}" && exit 5
|
||||
# pandoc -s -t markdown -- "${FILE_PATH}" && exit 5
|
||||
exit 1;;
|
||||
|
||||
## XLSX
|
||||
|
||||
Reference in New Issue
Block a user