diff --git a/.config/ranger/commands.py b/.config/ranger/commands.py index 97b7909..f803f45 100644 --- a/.config/ranger/commands.py +++ b/.config/ranger/commands.py @@ -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')) diff --git a/.config/ranger/rc.conf b/.config/ranger/rc.conf index 0e86e58..8e57ecb 100644 --- a/.config/ranger/rc.conf +++ b/.config/ranger/rc.conf @@ -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 diff --git a/.config/ranger/rifle.conf b/.config/ranger/rifle.conf index 15f5863..accbe99 100644 --- a/.config/ranger/rifle.conf +++ b/.config/ranger/rifle.conf @@ -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 -- "$@" diff --git a/.config/ranger/scope.sh b/.config/ranger/scope.sh index 1dadeb1..265f398 100755 --- a/.config/ranger/scope.sh +++ b/.config/ranger/scope.sh @@ -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