From 2dc486fb891e65658dff83ab34ca8878756a6a90 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Fri, 18 Oct 2024 21:52:28 -0500 Subject: initial commit --- zscripts/.lfub.zsh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 zscripts/.lfub.zsh (limited to 'zscripts/.lfub.zsh') diff --git a/zscripts/.lfub.zsh b/zscripts/.lfub.zsh new file mode 100755 index 0000000..2e1f7f4 --- /dev/null +++ b/zscripts/.lfub.zsh @@ -0,0 +1,27 @@ +#!/bin/sh +# This is a wrapper script for lf 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/$USER-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 & + 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" -- cgit v1.2.3