aboutsummaryrefslogtreecommitdiff
path: root/config/lf/scripts/fzfub
diff options
context:
space:
mode:
Diffstat (limited to 'config/lf/scripts/fzfub')
-rw-r--r--config/lf/scripts/fzfub25
1 files changed, 25 insertions, 0 deletions
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