sixel
This commit is contained in:
parent
8be214e27e
commit
f4b63aad61
3 changed files with 32 additions and 26 deletions
1
lf/lfrc
Normal file
1
lf/lfrc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
set previewer '~/.config/scripts/p'
|
46
scripts/p
46
scripts/p
|
@ -2,39 +2,33 @@
|
||||||
# Preview files & dirs
|
# Preview files & dirs
|
||||||
file="$1"
|
file="$1"
|
||||||
|
|
||||||
# Helps with fzf_nav visualization
|
|
||||||
rfile() {
|
rfile() {
|
||||||
file "$1" | sed 's/,\s/\n/g'
|
file "$1" | sed 's/,\s/\n/g'
|
||||||
}
|
}
|
||||||
|
|
||||||
# If executable, run 'file' and exit
|
mime="$(file --mime-type "$(readlink -f $file)" -b)"
|
||||||
file "$file" | grep -q "executable" && rfile "$file" && exit
|
ROWS="$(tput lines)"
|
||||||
|
COLS="$(tput cols)"
|
||||||
|
|
||||||
# If directory, list contents
|
case "$mime" in
|
||||||
[ -d "$file" ] && (cd "$file" && /usr/bin/ls -A1Fx --color --group-directories-first) && exit
|
inode/directory)
|
||||||
|
(cd "$file" && /usr/bin/ls -A1Fx --color --group-directories-first) ;;
|
||||||
case $file in
|
image/*)
|
||||||
# Images
|
magick "$file" -geometry $((COLS*8))x$((ROWS*18)) sixel:-
|
||||||
*.jpeg) rfile "$file" ;;
|
echo ;;
|
||||||
*.png) rfile "$file" ;;
|
video/*)
|
||||||
*.jpg) rfile "$file" ;;
|
tt="$(ffprobe -v error -show_entries format=duration -of \
|
||||||
*.gif) rfile "$file" ;;
|
default=noprint_wrappers=1:nokey=1 "$file")" ;
|
||||||
*.svg) rfile "$file" ;;
|
ft="5" ;
|
||||||
# Videos
|
if [ "$ft" -ge "${tt%%.*}" ] ; then ft="0" ; fi
|
||||||
*.webm) rfile "$file" ;;
|
ffmpeg -hide_banner -loglevel error -ss "$ft" -i "$file" -vframes 1 \
|
||||||
*.mp4) rfile "$file" ;;
|
-f image2pipe - | magick - -geometry $((COLS*8))x$((ROWS*18)) sixel:- ;
|
||||||
*.flv) rfile "$file" ;;
|
echo ;;
|
||||||
*.mkv) rfile "$file" ;;
|
audio/*)
|
||||||
*.avi) rfile "$file" ;;
|
rfile "$file" ;;
|
||||||
*.m4v) rfile "$file" ;;
|
text/x-*) bat -p --color=always --no-pager "$file" ;;
|
||||||
# Audio
|
|
||||||
*.flac) rfile "$file" ;;
|
|
||||||
*.mp3) rfile "$file" ;;
|
|
||||||
*.ogg) rfile "$file" ;;
|
|
||||||
# Documents
|
|
||||||
*.pdf) pdftotext "$file" - || file "$file" ;;
|
*.pdf) pdftotext "$file" - || file "$file" ;;
|
||||||
*.csv) column -s, -t < "$file" || cat "$file" ;;
|
*.csv) column -s, -t < "$file" || cat "$file" ;;
|
||||||
# Other
|
|
||||||
*.html) links -dump "$file" || cat "$file" ;;
|
*.html) links -dump "$file" || cat "$file" ;;
|
||||||
*) ! [ -d "$file" ] && head -n 47 "$file" && printf "\n\n ..." ;;
|
*) ! [ -d "$file" ] && head -n 47 "$file" && printf "\n\n ..." ;;
|
||||||
esac
|
esac
|
||||||
|
|
11
shell/functions/nav
Normal file
11
shell/functions/nav
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
nav() {
|
||||||
|
fzf \
|
||||||
|
--cycle \
|
||||||
|
--height=60% \
|
||||||
|
--preview 'p {}' \
|
||||||
|
--preview-window=right,70% \
|
||||||
|
--prompt='⯈ ' \
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue