1
0
Fork 0
dotfiles/.local/bin/lf-ueberzug

21 lines
462 B
Plaintext
Raw Normal View History

2023-06-13 16:09:53 +02:00
#!/bin/sh
set -e
2024-01-02 19:09:46 +01:00
clean() {
exec 3>&-
rm "$FIFO_UEBERZUG"
2023-06-13 16:09:53 +02:00
}
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
2024-01-02 19:09:46 +01:00
command lf "$@"
2023-06-13 16:09:53 +02:00
else
2024-01-02 19:09:46 +01:00
[ ! -d "$XDG_CACHE_HOME/lf" ] && mkdir --parents "$XDG_CACHE_HOME/lf"
export FIFO_UEBERZUG="$XDG_CACHE_HOME/lf/ueberzug-$$"
mkfifo "$FIFO_UEBERZUG"
2024-01-02 19:09:46 +01:00
ueberzug layer -s -p json <"$FIFO_UEBERZUG" &
exec 3>"$FIFO_UEBERZUG"
trap clean EXIT
2024-01-29 20:46:03 +01:00
# shellcheck disable=2016
command lf -command 'set_previewer ueberzug' "$@" 3>&-
2023-06-13 16:09:53 +02:00
fi