blob: 309a0dcf099ad50c7d5af9ad29346875a087e414 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/bin/sh
# This is a wrapper script for lb that allows it to create image previews with
# ueberzug. This works in concert with the lf configuration file and the
# lf-cleaner script.
cleanuplf() {
exec 3>&-
\rm "$FIFO_UEBERZUG"
}
lfub() {
dircache=/tmp/lflastdir
lfopt="--last-dir-path=$dircache"
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
lf "$lfopt" "$@"
else
export FIFO_UEBERZUG="/tmp/ueberzug-$$"
mkfifo "$FIFO_UEBERZUG"
(ueberzug layer -s <"$FIFO_UEBERZUG" -p json &) >/dev/null 2>&1
exec 3>"$FIFO_UEBERZUG"
trap cleanuplf HUP INT QUIT TERM PWR EXIT
lf "$lfopt" "$@" 3>&-
fi
[ -f "$dircache" ] && dir="$(cat "$dircache")" && [ -d "$dir" ] && cd "$dir"
}
alias "lf=lfub"
|