From 66bff0b5ef46550866c959bb745a61363dc5331f Mon Sep 17 00:00:00 2001 From: Timmy Keller Date: Thu, 16 Jun 2022 15:19:16 -0500 Subject: zplug commit --- zsh/zscripts/.lfub.zsh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 zsh/zscripts/.lfub.zsh (limited to 'zsh/zscripts/.lfub.zsh') diff --git a/zsh/zscripts/.lfub.zsh b/zsh/zscripts/.lfub.zsh new file mode 100755 index 0000000..83b00c1 --- /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/$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