So I'm using the terminal file explorer
vifm and especially have a hotkey to open a shell in the current directory.
nnoremap s :shell<cr>
However, when I
exit this shell, I get back to
vifm. But I don't want to have
vifm still open after going to the shell. I want to kill
vifm and afterwards when I
exit the terminal, it should bring me to the grandparent process or kill the terminal emulator. I tried stuff like
nnoremap s :!./testscript.sh<cr>
where testscript.sh contains:
#!/bin/sh zsh & kill $PPID
, but I always get an error code 1 from the last command when doing this. However, the grandparent terminal opens (not in the current directory of vifm) without a child being created. Changing the script to
#!/bin/sh zsh & kill $PPID clear
Does also give me an error code and opens the grandparent terminal (not in the current directory of vifm) and changing the script to
#!/bin/sh kill $PPID zsh
Makes the now open terminal buggy (buffer for letters somehow breaks).
So what is the right way to open a terminal in the current directory while closing vifm without receiving an error code or messing up the buffer?
Edit: To clearify what I need this for. I want to prevent a usb-stick being busy. If the current shell isn't using the usb-stick anymore, but vifm is still inside a directory of the usb-stick, I can't unmount the stick. And I want to do this without exiting the terminal, but rather closing vifm beforehand.
Edit 2: Found the answer. It works with:
nnoremap s : let $PREVPWD = system('pwd') \| cd \| !cd $PREVPWD && exec zsh<cr>