blob: 2968843bf36fb8ca815ead36b89877b84727f82a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/bin/sh
if [ -d "$1" ]; then
if [ -x /bin/eza ] || [ -x /usr/bin/eza ]; then
eza -alhF --group-directories-first --color=always --icons -- "$1"
else
ls -lhAF --group-directories-first --color -- "$1"
fi
readme="$(find "$1" -maxdepth 1 -name "README.*" | head -1)"
[ -n "$readme" ] && preview "$readme"
exit
fi
alias highlight='highlight --out-format=ansi'
case "$1" in
'') echo "preview: file name required" >&2; exit 1 ;;
*.html) w3m -dump "$1" ;;
*.md) glow -s dark --width="${FZF_PREVIEW_COLUMNS:-"$(tput cols)"}" "$1" ;;
# *.vim) highlight --syntax=vim --replace-tabs=2 -- "$1" ;;
*.js|*.vim|*.lua) highlight -- "$1" ;;
*.txt|*.description|*.srt) cat -- "$1" ;;
*.png|*.jpg|*.jpeg|*.webp|*.mp3|*.ogg|*.mp4|*.mkv|*.webm) mediainfo -- "$1" ;;
*.info.json) jq -C . "$1" ;;
*.json|*.ipynb) highlight --syntax=json -- "$1" ;;
*.tar.gz|*.tgz) tar tzf "$1" ;;
*.tar.bz2|*.tbz2) tar tjf "$1" ;;
*.tar.xz|*.txz) tar tJf "$1" ;;
*.tar) tar tf "$1" ;;
*.zip|*.jar|*.war|*.ear|*.oxt) unzip -l "$1" ;;
*.rar) unrar l "$1" ;;
*.7z) 7z l "$1" ;;
*.zst) zstdcat "$1" ;;
*.[1-8]) man "$1" | col -b ;;
*.o) nm "$1" ;;
*.torrent) transmission-show "$1" ;;
*.iso) iso-info --no-header -l "$1" ;;
*odt|*.ods|*.odp|*.sxw) odt2txt "$1" ;;
*.doc) catdoc "$1" ;;
*.docx) docx2txt "$1" - ;;
# *.csv) sed s/,/\\n/g "$1" ;;
*)
filetype=$(file --dereference --brief --mime-type "$1")
case $filetype in
*html) w3m -dump "$1" ;;
text/markdown) glow -s dark -w "$(tput cols)" "$1" ;;
application/json) highlight --syntax=json --replace-tabs=2 -- "$1" ;;
text/*) highlight --force -- "$1" ;;
audio/*|video/*|image/*) mediainfo -- "$1" ;;
*xz) xz --list "$1" ;;
*zip|*tar*|*7z*|*bzip2) atool --list -- "$1" ;;
*opendocument*) odt2txt "$1" ;;
application/pgp-encrypted) gpg -d -- "$1" ;;
*) file -b "$1" ;;
esac
;;
esac
|