remove img_preview

This commit is contained in:
chenyc 2023-04-07 11:52:29 +08:00
parent ecc3249674
commit 4685ea6adc
4 changed files with 1 additions and 58 deletions

View File

@ -6,7 +6,7 @@ if [ -d "$1" ]; then
elif [ "$category" = text ]; then elif [ "$category" = text ]; then
(bat -p --color=always "$1" || cat "$1") 2>/dev/null | head -1000 (bat -p --color=always "$1" || cat "$1") 2>/dev/null | head -1000
elif [ "$category" = image ]; then elif [ "$category" = image ]; then
command -v ueberzug 2&>/dev/null && bash $OMZ/lib/img_preview.sh "$1"|| img2txt "$1" img2txt "$1"
else else
echo $1 is a $category file echo $1 is a $category file
fi fi

View File

@ -1,12 +0,0 @@
#!/bin/bash
exec < /dev/tty
oldstty=$(stty -g)
stty raw -echo min 0
echo -en "\033[6n" > /dev/tty
IFS=';' read -r -d R -a pos
stty $oldstty
row=$((${pos[0]:2} - 1))
col=$((${pos[1]} - 1))
echo "export row=$row" > $OMZ/cache/cursor
echo "export col=$col" >> $OMZ/cache/cursor

View File

@ -1,44 +0,0 @@
#!/usr/bin/env bash
declare -r -x DEFAULT_PREVIEW_POSITION="right"
declare -r -x UEBERZUG_FIFO="$(mktemp --dry-run --suffix "fzf-$$-ueberzug")"
declare -r -x PREVIEW_ID="preview"
function start_ueberzug {
mkfifo "${UEBERZUG_FIFO}"
<"${UEBERZUG_FIFO}" \
ueberzug layer --parser bash --silent &
3>"${UEBERZUG_FIFO}" \
exec
}
function finalise {
3>&- \
exec
&>/dev/null \
rm "${UEBERZUG_FIFO}"
&>/dev/null \
kill $(jobs -p)
killall ueberzug
}
function draw_preview {
source $OMZ/cache/cursor
X=$(($COLUMNS / 2 + 2))
Y=$((row + 2))
if [ $Y -gt $((LINES - 11)) ]; then
Y=$((LINES - 11))
fi
>"${UEBERZUG_FIFO}" declare -A -p cmd=( \
[action]=add [identifier]="${PREVIEW_ID}" \
[x]="${X}" [y]="${Y}" \
[width]="$(($COLUMNS / 2 - 2))" [height]="10" \
[scaler]=forced_cover [scaling_position_x]=0.5 [scaling_position_y]=0.5 \
[path]="${@}")
}
trap finalise EXIT
start_ueberzug
draw_preview $*
sleep 999999

View File

@ -211,7 +211,6 @@ fzf-tab-debug() {
} }
fzf-tab-complete() { fzf-tab-complete() {
bash $OMZ/lib/get_cursor.sh
# this name must be ugly to avoid clashes # this name must be ugly to avoid clashes
local -i _ftb_continue=1 _ftb_continue_last=0 _ftb_accept=0 ret=0 local -i _ftb_continue=1 _ftb_continue_last=0 _ftb_accept=0 ret=0
# hide the cursor until finishing completion, so that users won't see cursor up and down # hide the cursor until finishing completion, so that users won't see cursor up and down