I was trying to make the lfrun work with quit-on-cd which mentions a trick to cd to the current directory when quitting.
But for some reason its not working as expected.
If I run regular lf it exits and cds to expected directory but when I do lfrun it doesn't
Minimal ~/.config/lf/lfrc
```lfrc
set cleaner ~/.config/lf/cleaner
set previewer ~/.config/lf/preview
set shell bash
set shellopts '-eu'
set ifs "\n"
cmd quit-and-cd &{{
pwd > $LF_CD_FILE
notify-send "quit-and-cd" "$LF_CD_FILE\n$(cat $LF_CD_FILE)"
lf -remote "send $id quit"
}}
map Q quit-and-cd
```
Modified ~/.local/bin/lfrun
```bash
#!/bin/bash
set -e
cleanup() {
exec 3>&-
command rm "$FIFO_UEBERZUG"
}
lf() {
# https://github.com/gokcehan/lf/wiki/Tips#cd-to-current-directory-on-quit
export LF_CD_FILE=/var/tmp/.lfcd-$$
command lf $@
if [ -s "$LF_CD_FILE" ]; then
local DIR="$(realpath "$(cat "$LF_CD_FILE")")"
if [ "$DIR" != "$PWD" ]; then
echo "cd to $DIR"
cd "$DIR"
fi
command rm "$LF_CD_FILE"
fi
unset LF_CD_FILE
}
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
lf "$@"
else
[ ! -d "$HOME/.cache/lf" ] && mkdir --parents "$HOME/.cache/lf"
export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$"
mkfifo "$FIFO_UEBERZUG"
ueberzug layer -s -p json <"$FIFO_UEBERZUG" &
exec 3>"$FIFO_UEBERZUG"
# trap cleanup HUP INT QUIT TERM PWR EXIT # Also tried this one
trap cleanup HUP INT QUIT TERM PWR EXIT
lf "$@" 3>&-
fi
```
I was trying to make the lfrun work with quit-on-cd which mentions a trick to cd to the current directory when quitting. But for some reason its not working as expected. If I run regular lf it exits and cds to expected directory but when I do lfrun it doesn't
Minimal
```lfrc set cleaner ~/.config/lf/cleaner set previewer ~/.config/lf/preview set shell bash set shellopts '-eu' set ifs "\n" cmd quit-and-cd &{{ pwd > $LF_CD_FILE notify-send "quit-and-cd" "$LF_CD_FILE\n$(cat $LF_CD_FILE)" lf -remote "send $id quit" }} map Q quit-and-cd ```~/.config/lf/lfrc
Modified
```bash #!/bin/bash set -e cleanup() { exec 3>&- command rm "$FIFO_UEBERZUG" } lf() { # https://github.com/gokcehan/lf/wiki/Tips#cd-to-current-directory-on-quit export LF_CD_FILE=/var/tmp/.lfcd-$$ command lf $@ if [ -s "$LF_CD_FILE" ]; then local DIR="$(realpath "$(cat "$LF_CD_FILE")")" if [ "$DIR" != "$PWD" ]; then echo "cd to $DIR" cd "$DIR" fi command rm "$LF_CD_FILE" fi unset LF_CD_FILE } if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then lf "$@" else [ ! -d "$HOME/.cache/lf" ] && mkdir --parents "$HOME/.cache/lf" export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$" mkfifo "$FIFO_UEBERZUG" ueberzug layer -s -p json <"$FIFO_UEBERZUG" & exec 3>"$FIFO_UEBERZUG" # trap cleanup HUP INT QUIT TERM PWR EXIT # Also tried this one trap cleanup HUP INT QUIT TERM PWR EXIT lf "$@" 3>&- fi ```~/.local/bin/lfrun