summaryrefslogtreecommitdiff
path: root/zsh/zscripts/lfub.zsh
diff options
context:
space:
mode:
authorTimmy Keller <tjk@tjkeller.xyz>2022-03-16 23:32:06 -0500
committerTimmy Keller <tjk@tjkeller.xyz>2022-03-16 23:32:06 -0500
commit6f0ca4a0b6366b9c33e9366e08aa1b14e1037e8a (patch)
tree8511a9d4fb84d43a85f88492789b84a590dd0feb /zsh/zscripts/lfub.zsh
parent8699ed1e1ccd7cf1ee5af616f3a922204efa913c (diff)
downloaddotconfig-6f0ca4a0b6366b9c33e9366e08aa1b14e1037e8a.tar.xz
dotconfig-6f0ca4a0b6366b9c33e9366e08aa1b14e1037e8a.zip
zscripts and profiles
Diffstat (limited to 'zsh/zscripts/lfub.zsh')
-rwxr-xr-xzsh/zscripts/lfub.zsh27
1 files changed, 27 insertions, 0 deletions
diff --git a/zsh/zscripts/lfub.zsh b/zsh/zscripts/lfub.zsh
new file mode 100755
index 0000000..309a0dc
--- /dev/null
+++ b/zsh/zscripts/lfub.zsh
@@ -0,0 +1,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"