Various user configs

+ vifm: improve preview scripts
+ lite-xl: change fonts' locations
+ neovim: update config for nvim-tree.lua
This commit is contained in:
FollieHiyuki 2021-10-02 21:31:50 +07:00
parent 68b4e1d59f
commit ef76692015
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
12 changed files with 159 additions and 147 deletions

View File

@ -18,11 +18,11 @@ keymap.add { ["ctrl+q"] = "core:quit" }
------------------------------- Fonts ---------------------------------------- ------------------------------- Fonts ----------------------------------------
-- customize fonts: -- customize fonts:
style.font = renderer.font.load(HOME .. "/.local/share/fonts/Comic/ComicMono.ttf", 14 * SCALE) style.font = renderer.font.load(HOME .. "/.config/lite-xl/fonts/iosevka-regular.ttf", 14 * SCALE)
style.big_font = renderer.font.load(HOME .. "/.local/share/fonts/Comic/ComicMono.ttf", 16 * SCALE) style.big_font = renderer.font.load(HOME .. "/.config/lite-xl/fonts/iosevka-regular.ttf", 16 * SCALE)
style.code_font = renderer.font.load(HOME .. "/.config/lite-xl/fonts/iosevka-ss14-regular.ttf", 14 * SCALE) style.code_font = renderer.font.load(HOME .. "/.config/lite-xl/fonts/iosevka-regular.ttf", 14 * SCALE)
style.icon_font = renderer.font.load("/usr/local/share/lite-xl/fonts/icons.ttf", 18 * SCALE) style.icon_font = renderer.font.load("/usr/share/lite-xl/fonts/icons.ttf", 18 * SCALE)
style.icon_big_font = renderer.font.load("/usr/local/share/lite-xl/fonts/icons.ttf", 24 * SCALE) style.icon_big_font = renderer.font.load("/usr/share/lite-xl/fonts/icons.ttf", 24 * SCALE)
local italic = renderer.font.load(HOME .. "/.config/lite-xl/fonts/iosevka-ss14-italic.ttf", 14 * SCALE) local italic = renderer.font.load(HOME .. "/.config/lite-xl/fonts/iosevka-ss14-italic.ttf", 14 * SCALE)
style.syntax_fonts["comment"] = italic style.syntax_fonts["comment"] = italic

View File

@ -377,7 +377,13 @@ function M.nvimtree_conf()
require('nvim-tree').setup { require('nvim-tree').setup {
open_on_setup = false, open_on_setup = false,
ignore_ft_on_setup = {'dashboard', 'alpha'},
auto_close = true, auto_close = true,
open_on_tab = false,
update_to_buf_dir = {
enable = false,
auto_open = true
},
hijack_cursor = true, hijack_cursor = true,
update_cwd = true, update_cwd = true,
lsp_diagnostics = true, lsp_diagnostics = true,

View File

@ -0,0 +1,6 @@
#!/bin/sh
# Alternatively just do 'set previewoptions=hardgraphicsclear' in vifmrc
printf '\33[s\33[5A\33[2K\33[u' # see vifm/vifm#588
clear
exit 0

View File

@ -1,19 +1,21 @@
#!/bin/sh #!/bin/sh
[ -d "$HOME/.cache/vifm" ] || mkdir -p "$HOME/.cache/vifm"
X="$2" X="$2"
Y="$3" Y="$3"
WIDTH="$4" WIDTH="$4"
HEIGHT="$5" HEIGHT="$5"
TMP="/tmp/vifm_thumb.png" TMP="$HOME/.cache/vifm/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')"
_preview_video() { _preview_video() {
ffmpegthumbnailer -i "$1" -o "$TMP" -s 0 [ ! -f "${TMP}.jpg" ] && ffmpegthumbnailer -i "$1" -o "${TMP}.jpg" -s 0
kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "$TMP" kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "${TMP}.jpg"
} }
_preview_image() { _preview_image() {
convert -- "$1" "$TMP" [ ! -f "${TMP}.jpg" ] && convert "$1"'[0]' "${TMP}.jpg"
kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "$TMP" kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "${TMP}.jpg"
} }
case "$1" in case "$1" in
@ -29,8 +31,8 @@ case "$1" in
image/*) image/*)
_preview_image "$1" ;; _preview_image "$1" ;;
application/font*|application/*opentype|font/*) application/font*|application/*opentype|font/*)
genfontimage "$1" "$TMP" [ ! -f "${TMP}.jpg" ] && genfontimage "$1" "${TMP}.jpg"
kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "$TMP" ;; kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "${TMP}.jpg" ;;
video/*) video/*)
_preview_video "$1" ;; _preview_video "$1" ;;
*) *)

View File

@ -1,22 +1,68 @@
#!/bin/sh #!/bin/sh
[ -d "$HOME/.cache/vifm" ] || mkdir -p ~/.cache/vifm
WIDTH="$2" WIDTH="$2"
HEIGHT="$3" HEIGHT="$3"
TMP="/tmp/vifm_thumb.png" TMP="$HOME/.cache/vifm/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')"
_show_sixel() {
# Stolen from vifm/vifm#419
pw=$(($2*8))
ph=$(($3*21))
w=$(exiftool -m -p '$ImageWidth' "$1")
h=$(exiftool -m -p '$ImageHeight' "$1")
height=auto
width=auto
if [ $pw -lt $w ] && [ $ph -lt $h ]
then
newh=$(echo "($h*$pw)/$w" | bc)
# neww=$(echo "($w*$ph)/$h" | bc)
if [ $newh -le $ph ]; then
width=$pw
else
height=$ph
fi
elif [ $pw -lt $w ]
then
width=$pw
elif [ $ph -lt $h ]
then
height=$ph
fi
# debugging stuff
# echo pw=$pw ph=$ph
# echo w=$w h=$h
# echo neww=$neww newh=$newh
# exec echo width=$width height=$height
# account for GNU screen
if [ -n "$STY" ]
then
popt=-P
fi
exec img2sixel $popt --width=$width --height=$height "$1" # require libsixel
# exec montage "$1" -geometry "${pw}x${ph}" sixel:- # require ImageMagick
}
_preview_video() { _preview_video() {
ffmpegthumbnailer -i "$1" -o "$TMP" -s 0 [ ! -f "${TMP}.jpg" ] && ffmpegthumbnailer -i "$1" -o "${TMP}.jpg" -s 0
show-sixel "$TMP" ${WIDTH} ${HEIGHT} _show_sixel "${TMP}.jpg" ${WIDTH} ${HEIGHT}
} }
_preview_image() { _preview_image() {
convert -- "$1" "$TMP" [ ! -f "${TMP}.jpg" ] && convert -- "$1"'[0]' "${TMP}.jpg"
show-sixel "$TMP" ${WIDTH} ${HEIGHT} _show_sixel "${TMP}.jpg" ${WIDTH} ${HEIGHT}
} }
case "$1" in case "$1" in
# First check common extensions # First check common extensions
*.png|*.jpg|*.bmp|*.jpeg|*.gif|*.xpm) show-sixel "$1" ${WIDTH} ${HEIGHT} ;; *.png|*.jpg|*.bmp|*.jpeg|*.gif|*.xpm) _show_sixel "$1" ${WIDTH} ${HEIGHT} ;;
*.avi|*.mp4|*.wmv|*.dat|*.3gp|*.vob|*.ogv|*.mkv|*.mpe?g|*.fl[icv]|*.m2v|*.webm|*.m?ts|*.r[am]|*.qt|*.divx|*.as[fx]|*.m4v|*.mov) _preview_video "$1" ;; *.avi|*.mp4|*.wmv|*.dat|*.3gp|*.vob|*.ogv|*.mkv|*.mpe?g|*.fl[icv]|*.m2v|*.webm|*.m?ts|*.r[am]|*.qt|*.divx|*.as[fx]|*.m4v|*.mov) _preview_video "$1" ;;
# Then fallback to mimetypes # Then fallback to mimetypes
*) *)
@ -27,8 +73,8 @@ case "$1" in
image/*) image/*)
_preview_image "$1" ;; _preview_image "$1" ;;
application/font*|application/*opentype|font/*) application/font*|application/*opentype|font/*)
genfontimage "$1" "$TMP" [ ! -f "${TMP}.jpg" ] && genfontimage "$1" "${TMP}.jpg"
show-sixel "$TMP" ${WIDTH} ${HEIGHT} ;; _show_sixel "${TMP}.jpg" ${WIDTH} ${HEIGHT} ;;
video/*) video/*)
_preview_video "$1" ;; _preview_video "$1" ;;
*) *)

View File

@ -34,7 +34,6 @@ case "$1" in
then then
echo "" echo ""
else else
echo "\0"
exa -1a --sort=type --color always --icons "$1" exa -1a --sort=type --color always --icons "$1"
fi ;; fi ;;
application/zip | application/x-tar | application/x-rar | application/x-7z-compressed | application/x-xz | application/x-bzip2 | application/x-gzip) application/zip | application/x-tar | application/x-rar | application/x-7z-compressed | application/x-xz | application/x-bzip2 | application/x-gzip)
@ -46,8 +45,7 @@ case "$1" in
video/*) video/*)
mediainfo "$1" || exiftool "$1" || fprobe -pretty "$1" 2>&1 ;; mediainfo "$1" || exiftool "$1" || fprobe -pretty "$1" 2>&1 ;;
text/* | */xml) text/* | */xml)
# vifm doesn't support 24bit color for now bat --style=plain --color=always "$1" ;;
env -uCOLORTERM bat --style=plain --color=always "$1" ;;
*) *)
echo '----- File Type Classification -----' && file --dereference --brief -- "$1" ;; echo '----- File Type Classification -----' && file --dereference --brief -- "$1" ;;
esac ;; esac ;;

View File

@ -1,49 +0,0 @@
#!/bin/sh
# Stolen from vifm/vifm#419
if [ "$#" -ne 3 ]
then
echo "Usage: $0 filename width height"
exit 1
fi
pw=$(($2*8))
ph=$(($3*21))
w=$(exiftool -m -p '$ImageWidth' "$1")
h=$(exiftool -m -p '$ImageHeight' "$1")
height=auto
width=auto
if [ $pw -lt $w ] && [ $ph -lt $h ]
then
newh=$(echo "($h*$pw)/$w" | bc)
# neww=$(echo "($w*$ph)/$h" | bc)
if [ $newh -le $ph ]; then
width=$pw
else
height=$ph
fi
elif [ $pw -lt $w ]
then
width=$pw
elif [ $ph -lt $h ]
then
height=$ph
fi
# debugging stuff
# echo pw=$pw ph=$ph
# echo w=$w h=$h
# echo neww=$neww newh=$newh
# exec echo width=$width height=$height
# account for GNU screen
if [ -n "$STY" ]
then
popt=-P
fi
exec img2sixel $popt --width=$width --height=$height "$1"

View File

@ -5,7 +5,7 @@ set vicmd=nvim
" Preview by default " Preview by default
view view
" set previewoptions=graphicsdelay:50000,hardgraphicsclear set previewoptions=graphicsdelay:50000,hardgraphicsclear
" This makes vifm perform file operations on its own instead of relying on " This makes vifm perform file operations on its own instead of relying on
" standard utilities like `cp`. While using `cp` and alike is a more universal " standard utilities like `cp`. While using `cp` and alike is a more universal
@ -25,7 +25,7 @@ set number
set trash set trash
" This is how many directories to store in the directory history. " This is how many directories to store in the directory history.
set history=100 set history=1000
" Automatically resolve symbolic links on l or Enter (only for files). " Automatically resolve symbolic links on l or Enter (only for files).
set nofollowlinks set nofollowlinks
@ -42,7 +42,7 @@ set undolevels=100
" Use Vim's format of help file (has highlighting and "hyperlinks"). " Use Vim's format of help file (has highlighting and "hyperlinks").
" If you would rather use a plain text help file set novimhelp. " If you would rather use a plain text help file set novimhelp.
set vimhelp set novimhelp
" If you would like to run an executable file when you " If you would like to run an executable file when you
" press return on the file name set this. " press return on the file name set this.
@ -99,7 +99,7 @@ set slowfs=curlftpfs
" set milleroptions=lsize:1,csize:3 " set milleroptions=lsize:1,csize:3
" Set custom status line look " Set custom status line look
set statusline=" %t%[ -> %T%]%= %A %10u:%-7g %5E %5a %20d " set statusline=' %t%[ -> %T%]%= %A %10u:%-7g %5E %5a %20d '
" Set custom ruler line look " Set custom ruler line look
set rulerformat='%2l/%S%[ +%x%]' set rulerformat='%2l/%S%[ +%x%]'
@ -137,6 +137,7 @@ command! make !!make %a
command! mkcd :mkdir %a | cd %a command! mkcd :mkdir %a | cd %a
command! vgrep nvim "+grep %a" command! vgrep nvim "+grep %a"
command! reload :write | restart command! reload :write | restart
command! exif exiftool -all= -overwrite_original %f
" fzf file " fzf file
command! fzf : let $FZF_RES = term('fzf --preview-window left --preview "$HOME/.local/bin/garbage/preview {} 2>/dev/null" 2>&0') command! fzf : let $FZF_RES = term('fzf --preview-window left --preview "$HOME/.local/bin/garbage/preview {} 2>/dev/null" 2>&0')
@ -211,7 +212,7 @@ filextype *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
filextype *.html,*.htm,*.xhtml filextype *.html,*.htm,*.xhtml
\ firefox %f &, \ firefox %f &,
\ qutebrowser %f &, \ qutebrowser %f &,
filetype *.html,*.htm,*.xhtml lynx %f filetype *.html,*.htm,*.xhtml nvim %f
" Object " Object
filetype *.o nm %f | less filetype *.o nm %f | less
@ -310,30 +311,27 @@ filextype *.pro qtcreator %f &
" mbox " mbox
filetype *.mbox neomutt -f filetype *.mbox neomutt -f
" Directories
filextype */
\ pcmanfm %f &,
filextype [\.]*/
\ pcmanfm %f &,
" filextype * xdg-open " filextype * xdg-open
" ------------------------------------------------------------------------------ " ------------------------------------------------------------------------------
" if $TERM == 'foot' if $TERM == 'foot'
" fileviewer <image/*>,<video/*>,<application/font*>,<application/*opentype>,<font/*> fileviewer <image/*>,<video/*>,<application/font*>,<application/*opentype>,<font/*>
" \ preview_sixel %c:p %pw %ph %pc clear %pd 2>/dev/null \ preview_sixel %c:p %pw %ph %pd 2>/dev/null
" elseif $TERM == 'xterm-kitty' elseif $TERM == 'xterm-kitty'
" fileviewer <image/*>,<video/*>,<application/font*>,<application/*opentype>,<font/*> fileviewer <image/*>,<video/*>,<application/font*>,<application/*opentype>,<font/*>
" \ preview_kitty %c:p %px %py %pw %ph %pc kitty icat --silent --clear %pd 2>/dev/null \ preview_kitty %c:p %px %py %pw %ph %pc kitty icat --silent --clear %pd 2>/dev/null
" endif endif
" fileviewer <*> fileviewer <*> preview_vifm %c:p 2>/dev/null
" \ preview_vifm %c:p 2>/dev/null
" ------------------------------------------------------------------------------ " ------------------------------------------------------------------------------
" Sample mappings " Quick way to select all files in the view
nnoremap VV :%select<cr>
" Tag a file and move down to the next one
nmap <space> tj
" Start shell in current directory " Start shell in current directory
nnoremap s :shell<cr> nnoremap s :shell<cr>
@ -341,12 +339,14 @@ nnoremap s :shell<cr>
" Display sorting dialog " Display sorting dialog
nnoremap S :sort<cr> nnoremap S :sort<cr>
" Toggle visibility of preview window " Toggle preview, and within preview toggle wrap
nnoremap w :view<cr> nnoremap w :view<cr>
vnoremap w :view<cr>gv vnoremap w :view<cr>gv
nnoremap W :set wrap!<cr>
" Open file in the background using its default program " Grow/shrink window by 4 columns at a time
nnoremap gb :file &<cr>l nnoremap < 4<c-w><
nnoremap > 4<c-w>>
" go to project root " go to project root
nnoremap gr :cd $PWD<cr> nnoremap gr :cd $PWD<cr>
@ -366,18 +366,9 @@ nnoremap I cw<c-a>
nnoremap cc cw<c-u> nnoremap cc cw<c-u>
nnoremap A cw nnoremap A cw
" q to quit
nnoremap q :q<cr>
" Open console in current directory
nnoremap ,t :!alacritty &<cr>
" Open editor to edit vifmrc and apply settings after returning to vifm " Open editor to edit vifmrc and apply settings after returning to vifm
nnoremap ,c :write | edit $MYVIFMRC | restart<cr> nnoremap ,c :write | edit $MYVIFMRC | restart<cr>
" Toggle wrap setting on ,w key
nnoremap ,w :set wrap!<cr>
" Example of standard two-panel file managers mappings " Example of standard two-panel file managers mappings
nnoremap <f3> :!less %f<cr> nnoremap <f3> :!less %f<cr>
nnoremap <f4> :edit<cr> nnoremap <f4> :edit<cr>
@ -386,13 +377,19 @@ nnoremap <f6> :move<cr>
nnoremap <f7> :mkdir<space> nnoremap <f7> :mkdir<space>
nnoremap <f8> :delete<cr> nnoremap <f8> :delete<cr>
" tabs " Tabs
nnoremap <C-t> :tabnew<cr> nnoremap <C-t> :tabnew<cr>
" map for fzf commands " Map for fzf commands
nnoremap <C-p> :fzf<cr> nnoremap <C-p> :fzf<cr>
nnoremap <C-n> :fzd<cr> nnoremap <C-n> :fzd<cr>
" Scroll in preview window
nnoremap <PageDown> <C-w>w5j<C-w>w
nnoremap <PageUp> <C-w>w5k<C-w>w
nnoremap J <C-w>w5j<C-w>w
nnoremap K <C-w>w5k<C-w>w
" ------------------------------------------------------------------------------ " ------------------------------------------------------------------------------
" Icons " Icons
@ -420,10 +417,10 @@ set classify+=' ::*.php::'
set classify+=' ::*.markdown,,*.md::' set classify+=' ::*.markdown,,*.md::'
set classify+=' ::*.json::' set classify+=' ::*.json::'
set classify+=' ::*.js::' set classify+=' ::*.js::'
set classify+=' ::*.bmp,,*.gif,,*.ico,,*.jpeg,,*.jpg,,*.png,,*.svg,,*.svgz,,*.tga,,*.tiff,,*.xmb,,*.xcf,,*.xpm,,*.xspf,,*.xwd,,*.cr2,,*.dng,,*.3fr,,*.ari,,*.arw,,*.bay,,*.crw,,*.cr3,,*.cap,,*.data,,*.dcs,,*.dcr,,*drf,,*.eip,,*.erf,,*.fff,,*.gpr,,*.iiq,,*.k25,,*.kdc,,*.mdc,,.*mef,,*.mos,,.*.mrw,,.*.obm,,*.orf,,*.pef,,*.ptx,,*.pxn,,*.r3d,,*.raf,,*.raw,,*.rwl,,*.rw2,,*.rwz,,*.sr2,,*.srf,,*.srf,,*.srw,,*.tif,,*.x3f::' set classify+=' ::*.bmp,,*.gif,,*.ico,,*.jpeg,,*.jpg,,*.png,,*.svg,,*.svgz,,*.tga,,*.tiff,,*.xmb,,*.xcf,,*.xpm,,*.xspf,,*.xwd,,*.cr2,,*.dng,,*.3fr,,*.ari,,*.arw,,*.bay,,*.crw,,*.cr3,,*.cap,,*.data,,*.dcs,,*.dcr,,*drf,,*.eip,,*.erf,,*.fff,,*.gpr,,*.iiq,,*.k25,,*.kdc,,*.mdc,,*.mef,,*.mos,,*.mrw,,*.obm,,*.orf,,*.pef,,*.ptx,,*.pxn,,*.r3d,,*.raf,,*.raw,,*.rwl,,*.rw2,,*.rwz,,*.sr2,,*.srf,,*.srf,,*.srw,,*.tif,,*.x3f::'
set classify+=' ::*.ejs,,*.htm,,*.html,,*.slim,,*.xml::' set classify+=' ::*.ejs,,*.htm,,*.html,,*.slim,,*.xml::'
set classify+=' ::*.mustasche::' set classify+=' ::*.mustasche::'
set classify+=' ::*.css,,*.less,,*.bat,,*.conf,,*.ini,,*.rc,,*.yml,,*.cfg,,*.rc::' set classify+=' ::*.css,,*.less,,*.bat,,*.conf,,*.ini,,*.rc,,*.yml,,*.cfg::'
set classify+=' ::*.rss::' set classify+=' ::*.rss::'
set classify+=' ::*.coffee::' set classify+=' ::*.coffee::'
set classify+=' ::*.twig::' set classify+=' ::*.twig::'
@ -455,7 +452,7 @@ set classify+=' ::*.psb,,*.psd::'
set classify+=' ::*.jsx::' set classify+=' ::*.jsx::'
set classify+=' ::*.vim,,*.vimrc::' set classify+=' ::*.vim,,*.vimrc::'
set classify+=' ::*.aac,,*.anx,,*.asf,,*.au,,*.axa,,*.flac,,*.m2a,,*.m4a,,*.mid,,*.midi,,*.mp3,,*.mpc,,*.oga,,*.ogg,,*.ogx,,*.ra,,*.ram,,*.rm,,*.spx,,*.wav,,*.wma,,*.ac3::' set classify+=' ::*.aac,,*.anx,,*.asf,,*.au,,*.axa,,*.flac,,*.m2a,,*.m4a,,*.mid,,*.midi,,*.mp3,,*.mpc,,*.oga,,*.ogg,,*.ogx,,*.ra,,*.ram,,*.rm,,*.spx,,*.wav,,*.wma,,*.ac3::'
set classify+=' ::*.avi,,*.flv,,*.mkv,,*.mov,,*.mov,,*.mp4,,*.mpeg,,*.mpg,,*.webm::' set classify+=' ::*.avi,,*.flv,,*.mkv,,*.mov,,*.mp4,,*.mpeg,,*.mpg,,*.webm::'
set classify+=' ::*.epub,,*.pdf,,*.fb2,,*.djvu::' set classify+=' ::*.epub,,*.pdf,,*.fb2,,*.djvu::'
set classify+=' ::*.7z,,*.apk,,*.bz2,,*.cab,,*.cpio,,*.deb,,*.gem,,*.gz,,*.gzip,,*.lh,,*.lzh,,*.lzma,,*.rar,,*.rpm,,*.tar,,*.tgz,,*.xz,,*.zip,,*.zstd::' set classify+=' ::*.7z,,*.apk,,*.bz2,,*.cab,,*.cpio,,*.deb,,*.gem,,*.gz,,*.gzip,,*.lh,,*.lzh,,*.lzma,,*.rar,,*.rpm,,*.tar,,*.tgz,,*.xz,,*.zip,,*.zstd::'
set classify+=' ::*.cbr,,*.cbz::' set classify+=' ::*.cbr,,*.cbz::'

View File

@ -1,19 +1,20 @@
#!/bin/sh #!/bin/sh
# For using with fzf # For using with fzf
[ -d "$HOME/.cache/fzf" ] || mkdir -p "$HOME/.cache/fzf"
X="2" X="2"
Y="1" Y="1"
WIDTH="$FZF_PREVIEW_COLUMNS" WIDTH="$FZF_PREVIEW_COLUMNS"
HEIGHT="$FZF_PREVIEW_LINES" HEIGHT="$FZF_PREVIEW_LINES"
TMP="/tmp/fzf_thumb.png" TMP="$HOME/.cache/fzf/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')"
# Handy functions for convenience # Handy functions for convenience
preview_img() { preview_img() {
if [ "$TERM" = "xterm-kitty" ] if [ "$TERM" = "xterm-kitty" ]
then then
convert -- "$1" "$TMP" [ ! -f "${TMP}.jpg" ] && convert "$1"'[0]' "${TMP}.jpg"
kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "$TMP" kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "${TMP}.jpg"
else else
mediainfo "$1" || exiftool "$1" || identify "$1" mediainfo "$1" || exiftool "$1" || identify "$1"
fi fi
@ -22,14 +23,14 @@ preview_img() {
preview_vid() { preview_vid() {
if [ "$TERM" = "xterm-kitty" ] if [ "$TERM" = "xterm-kitty" ]
then then
ffmpegthumbnailer -i "$1" -o "$TMP" -s 0 [ ! -f "${TMP}.jpg" ] && ffmpegthumbnailer -i "$1" -o "${TMP}.jpg" -s 0
kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "$TMP" kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "${TMP}"
else else
mediainfo "$1" || exiftool "$1" || fprobe -pretty "$1" 2>&1 mediainfo "$1" || exiftool "$1" || fprobe -pretty "$1" 2>&1
fi fi
} }
# Clear the old image before processing, otherwise shit will happen # Clear the old image before processing, otherwise shit happens
if [ "$TERM" = "xterm-kitty" ] if [ "$TERM" = "xterm-kitty" ]
then then
kitty icat --silent --clear kitty icat --silent --clear
@ -84,8 +85,8 @@ case "$1" in
application/font*|application/*opentype|font/*) application/font*|application/*opentype|font/*)
if [ "$TERM" = "xterm-kitty" ] if [ "$TERM" = "xterm-kitty" ]
then then
genfontimage "$1" "$TMP" [ ! -f "${TMP}.jpg" ] && genfontimage "$1" "${TMP}.jpg"
kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "$TMP" kitty icat --silent --place=${WIDTH}x${HEIGHT}@${X}x${Y} "${TMP}.jpg"
else else
echo '----- Font Classification -----' && file --dereference --brief -- "$1" echo '----- Font Classification -----' && file --dereference --brief -- "$1"
fi ;; fi ;;

View File

@ -4,6 +4,11 @@ PREVIEW_TEXT="ABCDEFGHIJKLM\nNOPQRSTUVWXYZ\nabcdefghijklm\nnopqrstuvwxyz\n123456
BG="#2e3440" BG="#2e3440"
FG="#eceff4" FG="#eceff4"
if [ "$#" -ne 2 ]; then
echo "Usage: $0 filename output_image"
exit 1
fi
convert -size 800x800 xc:"$BG" \ convert -size 800x800 xc:"$BG" \
-gravity center \ -gravity center \
-pointsize 40 \ -pointsize 40 \