lf: various fixes
This commit is contained in:
parent
31b5f9d0c5
commit
f23cb900c5
2 changed files with 28 additions and 9 deletions
|
@ -121,7 +121,7 @@ cmd fzf ${{
|
|||
--nth="$field" \
|
||||
--with-nth="$field" \
|
||||
--preview-window="right,$width" \
|
||||
--bind="space:accept,focus:transform-preview-label(echo {} | cut -d '$delimiter' -f '$path_field')" \
|
||||
--bind="focus:transform-preview-label(echo {} | cut -d '$delimiter' -f '$path_field')" \
|
||||
--tiebreak="begin" \
|
||||
--header="$name" \
|
||||
--preview='
|
||||
|
@ -241,7 +241,7 @@ map <a-enter> shell-wait
|
|||
map <tab><tab> find_project
|
||||
map <tab>t fzf 'Tags' 'cat $XDG_DATA_HOME/lf/tags 2>/dev/null' ':' '1' '1' '50%'
|
||||
map <tab>m fzf 'Marks' 'cat $XDG_DATA_HOME/lf/marks 2>/dev/null' ':' '1' '2' '85%' '^'
|
||||
map <tab>f fzf 'Files' 'fd -L --full-path $PWD' ':' '1' '1' '50%'
|
||||
map <tab>f fzf 'Files' 'fd -uL --full-path $PWD' ':' '1' '1' '50%'
|
||||
map <tab>g find_word
|
||||
map "'" mark-load
|
||||
map '"' mark-remove
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
set -C -f
|
||||
|
||||
f="$(realpath "$1")" w=$2 h=$3 # x=$4 y=$5
|
||||
f="$(realpath "$1")" w=$2 h=$3 x=$4 y=$5
|
||||
|
||||
RED="\033[31m"
|
||||
RESET="\033[0m"
|
||||
RS="$(printf "\037")"
|
||||
CACHE="${XDG_CACHE_HOME}/lf/$(stat --printf "%n\0%i\0%F\0%s\0%W\0%Y" -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')"
|
||||
CACHE="${XDG_CACHE_HOME}/lf/$(stat --printf "%n %i %F %s %W %Y" -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')"
|
||||
SIZED_CACHE="${XDG_CACHE_HOME}/lf/$(stat --printf "%n %i %F %s %W %Y ${w} ${h}" -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')"
|
||||
BAT="bat --style=plain --color=always --italic-text=always --pager=never --tabs=4 --theme=base16 --line-range=:$h --terminal-width=$((w - 2))"
|
||||
CHAFA="chafa -f sixel -s ${w}x${h} --polite on --animate false"
|
||||
|
||||
|
@ -26,12 +27,19 @@ run() {
|
|||
}
|
||||
|
||||
cached_text() {
|
||||
if [ -f "$CACHE" ]; then
|
||||
if [ "$1" = "-s" ]; then
|
||||
cache="$SIZED_CACHE"
|
||||
shift
|
||||
else
|
||||
cache="$CACHE"
|
||||
fi
|
||||
|
||||
if [ -f "$cache" ]; then
|
||||
# shellcheck disable=SC2086
|
||||
$BAT "$CACHE"
|
||||
$BAT "$cache"
|
||||
else
|
||||
# shellcheck disable=SC2086
|
||||
run "$@" | tee -p "$CACHE" | $BAT
|
||||
run "$@" | tee -p "$cache" | $BAT
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -77,13 +85,24 @@ mimetest() {
|
|||
fi
|
||||
;;
|
||||
*/epub+zip) cached_image gnome-epub-thumbnailer -s 1024 "$f" "$CACHE" ;;
|
||||
image/svg+xml) cached_image inkscape --convert-dpi-method=none -o "${CACHE}.png" --export-overwrite -D --export-png-color-mode=RGBA_16 "$f" ;;
|
||||
image/svg+xml)
|
||||
cached_image inkscape \
|
||||
--convert-dpi-method=none \
|
||||
--export-filename=- \
|
||||
--export-overwrite \
|
||||
--export-area-drawing \
|
||||
--export-png-color-mode=RGBA_16 "$f"
|
||||
;;
|
||||
image/*) $CHAFA "$f" ;;
|
||||
*/pdf) cached_image pdftoppm -jpeg -f 1 -singlefile "$f" ;;
|
||||
video/*) cached_image ffmpegthumbnailer -s 0 -i "$f" -o "/dev/stdout" ;;
|
||||
*/vnd.oasis.opendocument.text) cached_text odt2txt "$f" ;;
|
||||
*/vnd.openxmlformats-officedocument.wordprocessingml.document) cached_text docx2txt "$f" - ;;
|
||||
*/markdown) cached_text mdless "$f" ;;
|
||||
*/markdown)
|
||||
export COLORTERM=truecolor
|
||||
export CLICOLOR_FORCE=1
|
||||
cached_text -s glow -w "$w" -s tokyo-night "$f"
|
||||
;;
|
||||
*/html) cached_text lynx -dump "$f" ;;
|
||||
*/*json) cached_text jq -C . "$f" ;;
|
||||
*/msword) cached_text catdoc "$f" ;;
|
||||
|
|
Loading…
Add table
Reference in a new issue