The wiki suggests using a shell function to allow for using vifm to change directories.
However, the function given there runs vifm in a subshell -
local dst="$(command vifm --choose-dir - "$@")"
Because of which it cannot be suspended and resumed with Ctrl-Z
Suspending and resuming is crucial to my workflow - often I end up opening and working on a file in vifm, and then I need to suspend the editor to run something in the terminal. I'm probably not the only person who does this, either.
I've tried to write my own script -
vicd () {
# Write output of --choose-dir
# to a temporary file; then set
# _dst using that file.
# clean up temporary files on unexpected exit
trap 'rm -f "$_tmp"' EXIT TERM INT HUP
local _tmp="$(mktemp)"
command vifm --choose-dir - "$@" > "$_tmp"
local _dst=$(cat "$_tmp")
rm "$_tmp"
if [ -z "$_dst" ]; then
echo "Directory picking cancelled/failed"
return 1
fi
cd "$_dst"
}
And I am able to suspend vifm this way - but after suspending, the directory is not changed. The directory only changes if vifm has not been suspended.
Does anyone have any ideas? I'm pretty stumped here.