|
|
|
@@ -3,17 +3,17 @@
|
|
|
|
|
|
|
|
|
|
# Description:
|
|
|
|
|
# View and manage clipboard history using fzf, with support for
|
|
|
|
|
# image previews in compatible terminals.
|
|
|
|
|
# image preview in compatible terminals.
|
|
|
|
|
# Requirements:
|
|
|
|
|
# - cliphist
|
|
|
|
|
# - wl-clipboard
|
|
|
|
|
# - fzf
|
|
|
|
|
# - sixel-query & kgp-query from this repository
|
|
|
|
|
# - chafa (for image previews)
|
|
|
|
|
# - sixel-query, kgp-query, iterm2-query from this repository
|
|
|
|
|
# - chafa (for image preview)
|
|
|
|
|
# - ffmpegthumbnailer (optional, for video thumbnails)
|
|
|
|
|
# Credits:
|
|
|
|
|
# - Original idea and some code adapted from https://github.com/SHORiN-KiWATA/shorinclip
|
|
|
|
|
# LICENSE:
|
|
|
|
|
# License:
|
|
|
|
|
# # MIT License
|
|
|
|
|
# #
|
|
|
|
|
# # Copyright (c) 2026 shorinkiwata
|
|
|
|
@@ -50,26 +50,26 @@ export C_RESET='\x1b[0m'
|
|
|
|
|
# Check for terminal graphics support and set environment variables accordingly
|
|
|
|
|
|
|
|
|
|
_check_kitty_icat() {
|
|
|
|
|
# workaround for WezTerm
|
|
|
|
|
if [ -n "${WEZTERM_EXECUTABLE:-}" ]; then
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
kgp-query
|
|
|
|
|
# workaround for WezTerm
|
|
|
|
|
if [ -n "${WEZTERM_EXECUTABLE:-}" ]; then
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
kgp-query
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_check_sixel() {
|
|
|
|
|
# workaround for Zellij
|
|
|
|
|
if [ -n "${ZELLIJ_SESSION_NAME:-}" ]; then
|
|
|
|
|
return 1
|
|
|
|
|
# same for tmux, unless otherwise configured
|
|
|
|
|
elif [ -n "${TMUX:-}" ]; then
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
sixel-query
|
|
|
|
|
# workaround for Zellij
|
|
|
|
|
if [ -n "${ZELLIJ_SESSION_NAME:-}" ]; then
|
|
|
|
|
return 1
|
|
|
|
|
# same for tmux, unless otherwise configured
|
|
|
|
|
elif [ -n "${TMUX:-}" ]; then
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
sixel-query
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_check_iterm2() {
|
|
|
|
|
iterm2-query
|
|
|
|
|
iterm2-query
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ENABLE_ICAT=0
|
|
|
|
@@ -78,11 +78,11 @@ ENABLE_ITERM2=0
|
|
|
|
|
|
|
|
|
|
# Priority: KGP > sixel > iterm2
|
|
|
|
|
if _check_kitty_icat; then
|
|
|
|
|
export ENABLE_ICAT=1
|
|
|
|
|
export ENABLE_ICAT=1
|
|
|
|
|
elif _check_sixel; then
|
|
|
|
|
export ENABLE_SIXEL=1
|
|
|
|
|
export ENABLE_SIXEL=1
|
|
|
|
|
elif _check_iterm2; then
|
|
|
|
|
export ENABLE_ITERM2=1
|
|
|
|
|
export ENABLE_ITERM2=1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
export ENABLE_ICAT
|
|
|
|
@@ -92,170 +92,170 @@ export ENABLE_ITERM2
|
|
|
|
|
# Preview functions
|
|
|
|
|
|
|
|
|
|
_preview_image() {
|
|
|
|
|
local file="$1"
|
|
|
|
|
if [ "$ENABLE_ICAT" -eq 1 ]; then
|
|
|
|
|
printf "\x1b_Ga=d\x1b\\"
|
|
|
|
|
chafa -f kitty --animate=off --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
|
|
|
|
elif [ "$ENABLE_SIXEL" -eq 1 ]; then
|
|
|
|
|
chafa -f sixels --animate=off --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
|
|
|
|
elif [ "$ENABLE_ITERM2" -eq 1 ]; then
|
|
|
|
|
chafa -f iterm2 --animate=off --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
|
|
|
|
else
|
|
|
|
|
chafa -f symbols --animate=off --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
|
|
|
|
fi
|
|
|
|
|
local file="$1"
|
|
|
|
|
if [ "$ENABLE_ICAT" -eq 1 ]; then
|
|
|
|
|
printf "\x1b_Ga=d\x1b\\"
|
|
|
|
|
chafa -f kitty --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
|
|
|
|
elif [ "$ENABLE_SIXEL" -eq 1 ]; then
|
|
|
|
|
chafa -f sixels --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
|
|
|
|
elif [ "$ENABLE_ITERM2" -eq 1 ]; then
|
|
|
|
|
chafa -f iterm2 -size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
|
|
|
|
else
|
|
|
|
|
chafa -f symbols --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
export -f _preview_image
|
|
|
|
|
|
|
|
|
|
_preview_text() {
|
|
|
|
|
local content="$1"
|
|
|
|
|
if [ "$ENABLE_ICAT" -eq 1 ]; then
|
|
|
|
|
printf "\x1b_Ga=d\x1b\\"
|
|
|
|
|
fi
|
|
|
|
|
echo "$content" | head -n 100
|
|
|
|
|
local content="$1"
|
|
|
|
|
if [ "$ENABLE_ICAT" -eq 1 ]; then
|
|
|
|
|
printf "\x1b_Ga=d\x1b\\"
|
|
|
|
|
fi
|
|
|
|
|
echo "$content" | head -n 100
|
|
|
|
|
}
|
|
|
|
|
export -f _preview_text
|
|
|
|
|
|
|
|
|
|
_preview_file() {
|
|
|
|
|
path="$1"
|
|
|
|
|
path_mime=$(file -b --mime-type "$path")
|
|
|
|
|
if [[ $path_mime =~ image ]]; then
|
|
|
|
|
_preview_image "$path"
|
|
|
|
|
elif [[ "$path_mime" =~ video ]]; then
|
|
|
|
|
video_hash=$(echo "$path" | md5sum | cut -d" " -f1)
|
|
|
|
|
thumb_file="$CACHE_DIR/$video_hash.png"
|
|
|
|
|
if [ ! -f "$thumb_file" ]; then
|
|
|
|
|
if command -v ffmpegthumbnailer &>/dev/null;then
|
|
|
|
|
ffmpegthumbnailer -i "$path" -o "$thumb_file" -s 480 -t 0 >/dev/null 2>&1
|
|
|
|
|
else
|
|
|
|
|
_preview_text "ffmpegthumbnailer not installed, cannot generate thumbnail for video."
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
if [ -s "$thumb_file" ]; then
|
|
|
|
|
_preview_image "$thumb_file"
|
|
|
|
|
else
|
|
|
|
|
_preview_text "Video: $path (No thumbnail)"
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
_preview_text "$path"
|
|
|
|
|
fi
|
|
|
|
|
path="$1"
|
|
|
|
|
path_mime=$(file -b --mime-type "$path")
|
|
|
|
|
if [[ $path_mime =~ image ]]; then
|
|
|
|
|
_preview_image "$path"
|
|
|
|
|
elif [[ "$path_mime" =~ video ]]; then
|
|
|
|
|
video_hash=$(echo "$path" | md5sum | cut -d" " -f1)
|
|
|
|
|
thumb_file="$CACHE_DIR/$video_hash.png"
|
|
|
|
|
if [ ! -f "$thumb_file" ]; then
|
|
|
|
|
if command -v ffmpegthumbnailer &>/dev/null; then
|
|
|
|
|
ffmpegthumbnailer -i "$path" -o "$thumb_file" -s 480 -t 0 >/dev/null 2>&1
|
|
|
|
|
else
|
|
|
|
|
_preview_text "ffmpegthumbnailer not installed, cannot generate thumbnail for video."
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
if [ -s "$thumb_file" ]; then
|
|
|
|
|
_preview_image "$thumb_file"
|
|
|
|
|
else
|
|
|
|
|
_preview_text "Video: $path (No thumbnail)"
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
_preview_text "$path"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
export -f _preview_file
|
|
|
|
|
|
|
|
|
|
preview() {
|
|
|
|
|
entry="$1"
|
|
|
|
|
entry="$1"
|
|
|
|
|
|
|
|
|
|
content=$(echo "$entry" | cut -f2-)
|
|
|
|
|
mimeType=$(echo "$entry" | cliphist decode | file -b --mime-type -)
|
|
|
|
|
ext=$(echo "$mimeType" | awk -F"/" "{print \$2}")
|
|
|
|
|
content=$(echo "$entry" | cut -f2-)
|
|
|
|
|
mimeType=$(echo "$entry" | cliphist decode | file -b --mime-type -)
|
|
|
|
|
ext=$(echo "$mimeType" | awk -F"/" "{print \$2}")
|
|
|
|
|
|
|
|
|
|
if [[ $mimeType =~ image ]]; then
|
|
|
|
|
img_hash=$(echo "$entry" | cliphist decode | md5sum | cut -d" " -f1)
|
|
|
|
|
cache_file="$CACHE_DIR/$img_hash.$ext"
|
|
|
|
|
[ -f "$cache_file" ] || echo "$entry" | cliphist decode > "$cache_file"
|
|
|
|
|
_preview_image "$cache_file"
|
|
|
|
|
if [[ $mimeType =~ image ]]; then
|
|
|
|
|
img_hash=$(echo "$entry" | cliphist decode | md5sum | cut -d" " -f1)
|
|
|
|
|
cache_file="$CACHE_DIR/$img_hash.$ext"
|
|
|
|
|
[ -f "$cache_file" ] || echo "$entry" | cliphist decode >"$cache_file"
|
|
|
|
|
_preview_image "$cache_file"
|
|
|
|
|
|
|
|
|
|
elif [ "$mimeType" = "text/html" ] && echo "$content" | grep -q QQ; then
|
|
|
|
|
qq_img_file=$(echo "$entry" | cliphist decode | grep -oP "^<img src=\"file://\K[^\"]+")
|
|
|
|
|
#qq_ext="${qq_img_file##*.}"
|
|
|
|
|
#qq_img_cache_file=$CACHE_DIR/$id.$qq_ext
|
|
|
|
|
#cp $qq_img_file $qq_img_cache_file
|
|
|
|
|
if [ -f "$qq_img_file" ]; then
|
|
|
|
|
_preview_image "$qq_img_file"
|
|
|
|
|
else
|
|
|
|
|
_preview_text "$qq_img_file does not exist."
|
|
|
|
|
fi
|
|
|
|
|
elif [ "$mimeType" = "text/html" ] && echo "$content" | grep -q QQ; then
|
|
|
|
|
qq_img_file=$(echo "$entry" | cliphist decode | grep -oP "^<img src=\"file://\K[^\"]+")
|
|
|
|
|
#qq_ext="${qq_img_file##*.}"
|
|
|
|
|
#qq_img_cache_file=$CACHE_DIR/$id.$qq_ext
|
|
|
|
|
#cp $qq_img_file $qq_img_cache_file
|
|
|
|
|
if [ -f "$qq_img_file" ]; then
|
|
|
|
|
_preview_image "$qq_img_file"
|
|
|
|
|
else
|
|
|
|
|
_preview_text "$qq_img_file does not exist."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
elif path=$(echo "$entry" | cliphist decode) && [[ "$path" == /* ]]; then
|
|
|
|
|
if [ -e "$path" ]; then
|
|
|
|
|
_preview_file "$path"
|
|
|
|
|
else
|
|
|
|
|
_preview_text "$path does not exist."
|
|
|
|
|
fi
|
|
|
|
|
elif decoded=$(echo "$entry" | cliphist decode) && [[ "$decoded" == file://* ]]; then
|
|
|
|
|
raw_path="${decoded#file://}"
|
|
|
|
|
raw_path=$(echo "$raw_path" | python -c "import sys, urllib.parse; print(urllib.parse.unquote(sys.stdin.read().strip()))")
|
|
|
|
|
if [ -e "$raw_path" ]; then
|
|
|
|
|
_preview_file "$raw_path"
|
|
|
|
|
else
|
|
|
|
|
_preview_text "$raw_path does not exist."
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
if [ "$ENABLE_ICAT" = 1 ]; then
|
|
|
|
|
printf "\x1b_Ga=d\x1b\\"
|
|
|
|
|
fi
|
|
|
|
|
_preview_text "$(echo "$entry" | cliphist decode)"
|
|
|
|
|
fi
|
|
|
|
|
elif path=$(echo "$entry" | cliphist decode) && [[ "$path" == /* ]]; then
|
|
|
|
|
if [ -e "$path" ]; then
|
|
|
|
|
_preview_file "$path"
|
|
|
|
|
else
|
|
|
|
|
_preview_text "$path does not exist."
|
|
|
|
|
fi
|
|
|
|
|
elif decoded=$(echo "$entry" | cliphist decode) && [[ "$decoded" == file://* ]]; then
|
|
|
|
|
raw_path="${decoded#file://}"
|
|
|
|
|
raw_path=$(echo "$raw_path" | python -c "import sys, urllib.parse; print(urllib.parse.unquote(sys.stdin.read().strip()))")
|
|
|
|
|
if [ -e "$raw_path" ]; then
|
|
|
|
|
_preview_file "$raw_path"
|
|
|
|
|
else
|
|
|
|
|
_preview_text "$raw_path does not exist."
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
if [ "$ENABLE_ICAT" = 1 ]; then
|
|
|
|
|
printf "\x1b_Ga=d\x1b\\"
|
|
|
|
|
fi
|
|
|
|
|
_preview_text "$(echo "$entry" | cliphist decode)"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
export -f preview
|
|
|
|
|
|
|
|
|
|
# Optimize entry formatting
|
|
|
|
|
|
|
|
|
|
format_clip_list() {
|
|
|
|
|
sed -E \
|
|
|
|
|
-e "s/(\t).*\.(mp4|mkv|webm|avi|mov|flv|wmv)$/\1${C_TERTIARY}[VIDEO]File.\2${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)file:\/\/.*\.(mp4|mkv|webm|avi|mov|flv|wmv)$/\1${C_TERTIARY}[VIDEO]Url.\2${C_RESET}/" \
|
|
|
|
|
-e "s/(\t).*src=\"file:\/\/.*[qQ][qQ].*/\1${C_PRIMARY}[IMG_HTML]QQ${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)file:\/\/.*xwechat.*temp.*/\1${C_PRIMARY}[IMG]WeChat${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)file:\/\/.*\.gif$/\1${C_PRIMARY}[IMG]Url.gif${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)file:\/\/.*\.(png|jpg|jpeg|webp|bmp)$/\1${C_TERTIARY}[IMG]Url.\2${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)file:\/\/.*/\1${C_CYAN}[URL]File${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)\/.*\.gif$/\1${C_PRIMARY}[IMG]Path.gif${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)\/.*\.(png|jpg|jpeg|webp|bmp)$/\1${C_TERTIARY}[IMG]Path.\2${C_RESET}/" \
|
|
|
|
|
-e "s/\[\[ binary data .* (png|jpg|jpeg|gif|webp) .*\]\]/${C_TERTIARY}[IMG]Bin.\1${C_RESET}/" \
|
|
|
|
|
-e "s/\[\[ binary data .* \]\]/${C_CYAN}[BINARY]${C_RESET}/"
|
|
|
|
|
sed -E \
|
|
|
|
|
-e "s/(\t).*\.(mp4|mkv|webm|avi|mov|flv|wmv)$/\1${C_TERTIARY}[VIDEO]File.\2${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)file:\/\/.*\.(mp4|mkv|webm|avi|mov|flv|wmv)$/\1${C_TERTIARY}[VIDEO]Url.\2${C_RESET}/" \
|
|
|
|
|
-e "s/(\t).*src=\"file:\/\/.*[qQ][qQ].*/\1${C_PRIMARY}[IMG_HTML]QQ${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)file:\/\/.*xwechat.*temp.*/\1${C_PRIMARY}[IMG]WeChat${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)file:\/\/.*\.gif$/\1${C_PRIMARY}[IMG]Url.gif${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)file:\/\/.*\.(png|jpg|jpeg|webp|bmp)$/\1${C_TERTIARY}[IMG]Url.\2${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)file:\/\/.*/\1${C_CYAN}[URL]File${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)\/.*\.gif$/\1${C_PRIMARY}[IMG]Path.gif${C_RESET}/" \
|
|
|
|
|
-e "s/(\t)\/.*\.(png|jpg|jpeg|webp|bmp)$/\1${C_TERTIARY}[IMG]Path.\2${C_RESET}/" \
|
|
|
|
|
-e "s/\[\[ binary data .* (png|jpg|jpeg|gif|webp) .*\]\]/${C_TERTIARY}[IMG]Bin.\1${C_RESET}/" \
|
|
|
|
|
-e "s/\[\[ binary data .* \]\]/${C_CYAN}[BINARY]${C_RESET}/"
|
|
|
|
|
}
|
|
|
|
|
export -f format_clip_list
|
|
|
|
|
|
|
|
|
|
add_num() {
|
|
|
|
|
awk -F '\t' '{printf "%s\t\x1b[90m%-2d \x1b[0m%s\n", $1, NR, $2}'
|
|
|
|
|
awk -F '\t' '{printf "%s\t\x1b[90m%-2d \x1b[0m%s\n", $1, NR, $2}'
|
|
|
|
|
}
|
|
|
|
|
export -f add_num
|
|
|
|
|
|
|
|
|
|
# Action when confirmed
|
|
|
|
|
|
|
|
|
|
copy_selection() {
|
|
|
|
|
local input="$1"
|
|
|
|
|
local decoded
|
|
|
|
|
decoded=$(echo "$input" | cliphist decode)
|
|
|
|
|
local mime
|
|
|
|
|
mime=$(echo "$decoded" | file -b --mime-type -)
|
|
|
|
|
local input="$1"
|
|
|
|
|
local decoded
|
|
|
|
|
decoded=$(echo "$input" | cliphist decode)
|
|
|
|
|
local mime
|
|
|
|
|
mime=$(echo "$decoded" | file -b --mime-type -)
|
|
|
|
|
|
|
|
|
|
url_encode() {
|
|
|
|
|
python -c "import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))" "$1"
|
|
|
|
|
}
|
|
|
|
|
url_encode() {
|
|
|
|
|
python -c "import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))" "$1"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Image
|
|
|
|
|
if [[ "$mime" =~ image ]]; then
|
|
|
|
|
echo "$decoded" | wl-copy
|
|
|
|
|
# Image
|
|
|
|
|
if [[ "$mime" =~ image ]]; then
|
|
|
|
|
echo "$decoded" | wl-copy
|
|
|
|
|
|
|
|
|
|
# HTML with QQ image
|
|
|
|
|
elif [ "$mime" = "text/html" ]; then
|
|
|
|
|
local qq_src
|
|
|
|
|
qq_src=$(echo "$decoded" | grep -oP "^<img src=\"file://\K[^\"]+")
|
|
|
|
|
# HTML with QQ image
|
|
|
|
|
elif [ "$mime" = "text/html" ]; then
|
|
|
|
|
local qq_src
|
|
|
|
|
qq_src=$(echo "$decoded" | grep -oP "^<img src=\"file://\K[^\"]+")
|
|
|
|
|
|
|
|
|
|
if [ -f "$qq_src" ]; then
|
|
|
|
|
local encoded_path
|
|
|
|
|
encoded_path=$(url_encode "$qq_src")
|
|
|
|
|
if [ -f "$qq_src" ]; then
|
|
|
|
|
local encoded_path
|
|
|
|
|
encoded_path=$(url_encode "$qq_src")
|
|
|
|
|
|
|
|
|
|
echo "file://$encoded_path" | wl-copy --type text/uri-list
|
|
|
|
|
else
|
|
|
|
|
echo "$decoded" | wl-copy
|
|
|
|
|
fi
|
|
|
|
|
echo "file://$encoded_path" | wl-copy --type text/uri-list
|
|
|
|
|
else
|
|
|
|
|
echo "$decoded" | wl-copy
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# URL starting with file://
|
|
|
|
|
elif [[ "$decoded" == file://* ]]; then
|
|
|
|
|
echo "$decoded" | wl-copy --type text/uri-list
|
|
|
|
|
# URL starting with file://
|
|
|
|
|
elif [[ "$decoded" == file://* ]]; then
|
|
|
|
|
echo "$decoded" | wl-copy --type text/uri-list
|
|
|
|
|
|
|
|
|
|
# file path
|
|
|
|
|
elif [[ "$decoded" == /* ]] && [ -e "$decoded" ]; then
|
|
|
|
|
local encoded_path
|
|
|
|
|
encoded_path=$(url_encode "$decoded")
|
|
|
|
|
echo "file://$encoded_path" | wl-copy --type text/uri-list
|
|
|
|
|
# file path
|
|
|
|
|
elif [[ "$decoded" == /* ]] && [ -e "$decoded" ]; then
|
|
|
|
|
local encoded_path
|
|
|
|
|
encoded_path=$(url_encode "$decoded")
|
|
|
|
|
echo "file://$encoded_path" | wl-copy --type text/uri-list
|
|
|
|
|
|
|
|
|
|
# Other data, just copy
|
|
|
|
|
else
|
|
|
|
|
echo "$decoded" | wl-copy
|
|
|
|
|
fi
|
|
|
|
|
# Other data, just copy
|
|
|
|
|
else
|
|
|
|
|
echo "$decoded" | wl-copy
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
export -f copy_selection
|
|
|
|
|
|
|
|
|
@@ -271,26 +271,25 @@ trap 'rm -rf "$CACHE_DIR"; kill $WATCH_PID 2>/dev/null' EXIT
|
|
|
|
|
|
|
|
|
|
wait_timeout=50
|
|
|
|
|
while [[ $(tput cols) -lt 35 || $(tput lines) -lt 25 ]]; do
|
|
|
|
|
printf "\rWaiting for terminal size at least 35x25... %d" "$wait_timeout"
|
|
|
|
|
sleep 1
|
|
|
|
|
((wait_timeout--))
|
|
|
|
|
[ "$wait_timeout" -eq 0 ] && exit 1
|
|
|
|
|
printf "\rWaiting for terminal size at least 35x25... %d" "$wait_timeout"
|
|
|
|
|
sleep 1
|
|
|
|
|
((wait_timeout--))
|
|
|
|
|
[ "$wait_timeout" -eq 0 ] && exit 1
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
cliphist list | format_clip_list | add_num | fzf \
|
|
|
|
|
--ansi \
|
|
|
|
|
--listen "$FZF_PORT" \
|
|
|
|
|
--bind "ctrl-r:reload($RELOAD_CMD)" \
|
|
|
|
|
--bind "ctrl-x:execute-silent(bash -c 'cliphist delete <<< \"\$1\"' -- {})+reload($RELOAD_CMD)" \
|
|
|
|
|
--prompt=" > " \
|
|
|
|
|
--header='CTRL-X: Delete | CTRL-R: Reload | ENTER: Paste' \
|
|
|
|
|
--color='header:italic:yellow,prompt:blue,pointer:blue' \
|
|
|
|
|
--info=hidden \
|
|
|
|
|
--no-sort \
|
|
|
|
|
--layout=reverse \
|
|
|
|
|
--with-nth 2.. \
|
|
|
|
|
--delimiter '\t' \
|
|
|
|
|
--preview-window=down:60%,wrap \
|
|
|
|
|
--preview "preview {}" \
|
|
|
|
|
--bind "enter:execute-silent(bash -c 'copy_selection \"\$1\"' -- {})+accept"
|
|
|
|
|
|
|
|
|
|
--ansi \
|
|
|
|
|
--listen "$FZF_PORT" \
|
|
|
|
|
--bind "ctrl-r:reload($RELOAD_CMD)" \
|
|
|
|
|
--bind "ctrl-x:execute-silent(bash -c 'cliphist delete <<< \"\$1\"' -- {})+reload($RELOAD_CMD)" \
|
|
|
|
|
--prompt=" > " \
|
|
|
|
|
--header='CTRL-X: Delete | CTRL-R: Reload | ENTER: Paste' \
|
|
|
|
|
--color='header:italic:yellow,prompt:blue,pointer:blue' \
|
|
|
|
|
--info=hidden \
|
|
|
|
|
--no-sort \
|
|
|
|
|
--layout=reverse \
|
|
|
|
|
--with-nth 2.. \
|
|
|
|
|
--delimiter '\t' \
|
|
|
|
|
--preview-window=down:60%,wrap \
|
|
|
|
|
--preview "preview {}" \
|
|
|
|
|
--bind "enter:execute-silent(bash -c 'copy_selection \"\$1\"' -- {})+accept"
|
|
|
|
|