aboutsummaryrefslogtreecommitdiff
path: root/config/lf
diff options
context:
space:
mode:
authorben <ben@nagy.contact>2025-05-03 15:03:39 -0700
committerben <ben@nagy.contact>2025-05-03 15:03:39 -0700
commit19d17fd83dcfc0052c39fb8f06c34879473faadc (patch)
tree4e56ad0bf1cabad120d548df5ff6716f526f0962 /config/lf
parented80e5df8c718fc2321904db1b81604d1ed33444 (diff)
more configs
Diffstat (limited to 'config/lf')
-rw-r--r--config/lf/lfrc4
-rw-r--r--config/lf/scripts/fzfub25
-rwxr-xr-xconfig/lf/scripts/lfub34
3 files changed, 63 insertions, 0 deletions
diff --git a/config/lf/lfrc b/config/lf/lfrc
new file mode 100644
index 0000000..290a104
--- /dev/null
+++ b/config/lf/lfrc
@@ -0,0 +1,4 @@
+set previewer ctpv
+set cleaner ctpvclear
+&ctpv -s $id
+&ctpvquit $id
diff --git a/config/lf/scripts/fzfub b/config/lf/scripts/fzfub
new file mode 100644
index 0000000..48d8b67
--- /dev/null
+++ b/config/lf/scripts/fzfub
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+case "$(uname -a)" in
+ *Darwin*) UEBERZUG_TMP_DIR="$TMPDIR" ;;
+ *) UEBERZUG_TMP_DIR="/tmp" ;;
+esac
+
+cleanup() {
+ ueberzugpp cmd -s "$SOCKET" -a exit
+}
+trap cleanup HUP INT QUIT TERM EXIT
+
+UB_PID_FILE="$UEBERZUG_TMP_DIR/.$(uuidgen)"
+ueberzugpp layer --no-stdin --silent --use-escape-codes --pid-file "$UB_PID_FILE"
+UB_PID=$(cat "$UB_PID_FILE")
+
+export SOCKET="$UEBERZUG_TMP_DIR"/ueberzugpp-"$UB_PID".socket
+
+# run fzf with preview
+fzf --reverse --preview="ueberzugpp cmd -s $SOCKET -i fzfpreview -a add \
+ -x \$FZF_PREVIEW_LEFT -y \$FZF_PREVIEW_TOP \
+ --max-width \$FZF_PREVIEW_COLUMNS --max-height \$FZF_PREVIEW_LINES \
+ -f {}"
+
+ueberzugpp cmd -s "$SOCKET" -a exit
diff --git a/config/lf/scripts/lfub b/config/lf/scripts/lfub
new file mode 100755
index 0000000..45864e5
--- /dev/null
+++ b/config/lf/scripts/lfub
@@ -0,0 +1,34 @@
+#!/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.
+
+set -e
+
+UB_PID=0
+UB_SOCKET=""
+
+case "$(uname -a)" in
+ *Darwin*) UEBERZUG_TMP_DIR="$TMPDIR" ;;
+ *) UEBERZUG_TMP_DIR="/tmp" ;;
+esac
+
+cleanup() {
+ exec 3>&-
+ ueberzugpp cmd -s "$UB_SOCKET" -a exit
+}
+
+if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
+ lf "$@"
+else
+ [ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf"
+ UB_PID_FILE="$UEBERZUG_TMP_DIR/.$(uuidgen)"
+ ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$UB_PID_FILE"
+ UB_PID=$(cat "$UB_PID_FILE")
+ rm "$UB_PID_FILE"
+ UB_SOCKET="$UEBERZUG_TMP_DIR/ueberzugpp-${UB_PID}.socket"
+ export UB_PID UB_SOCKET
+ trap cleanup HUP INT QUIT TERM EXIT
+ lf "$@" 3>&-
+fi