-
Notifications
You must be signed in to change notification settings - Fork 0
Home
pending details showing how to use thu.sh
iTerm2
, kitty
and foot
can render images with this script. Sixel support for other terminals is listed here https://www.arewesixelyet.com/.
Values below should be added to your ~/.Xresources
file before the session is started or restarted,
~/.Xresources
xterm*maxStringParse: 10000000
xterm*maxGraphicSize: 10000x10000
xterm*decTerminalID: vt340
xterm*numColorRegisters: 256
Many versions of foot
terminal emulator have a bug described here. When desktop or window scaling are used, foot
will render images in a smaller size. As a work-around use -z $SCALE
to apply a zoom factor to image sizes.
Using thu.sh
with ncurses file managers likely requires two things,
-
The filemanager must call
thu.sh -j
before ncurses is started. This reason for this is that ncurses takes control of stderr and stdout devices and preventsthu.sh
from using them to detect things like terminal size, cell size and sixel support.thu.sh -j
will query details from the terminal, to store and reuse them when rendering images. To learn more about this, see the discussion here. -
The filemanager must call
thu.sh
with the target filepath and view area size. eg,thu.sh -ck $PATH $WIDTH $HEIGHT
Download and extract thu.sh
to vifm's xdg ~/.config/vifm/scripts/ using one-liner below,
curl -sl \
https://api.github.com/repos/iambumblehead/thu.sh/releases/latest \
| grep "tarball_url" \
| cut -d\" -f4 \
| xargs curl -L -o thu.tar.gz \
&& tar -xf thu.tar.gz \
&& mv iambumblehead-thu.sh* thu \
&& cp thu/thu.sh ~/.config/vifm/scripts/ \
&& sleep 2; chmod +x ~/.config/vifm/scripts/thu.sh \
&& rm -rf thu thu.tar.gz
Update vifmrc
to use thu.sh
by including the let
and fileviewer
expressions below. Only this fileviewer should include the extensions it contains --remove other fileviewer expressions or matching extensions anywhere else in the vifmrc
file,
~/.config/vifm/vifmrc
" generates state session string with esc queried values,
" for example, cell pixel width and height and maximum supported image size
let $SESS = system('thu.sh -j')
" thu.sh is called with -ck
" '-c' tells thu.sh to process %pw and %ph as cell units
" '-k' tells thu.sh to use the state state session string from the '-j' call above
" '-z 3' include this with foot terminal emulator on scaled desktop
fileviewer {*.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm,*.svg,*.pdf,*.epub,
\*.ttf,*.otf,*.woff,*.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,
\*.ac3,*.og[agx],*.spx,*.opus,*.aac,*.mpga,*.avi,*.mp4,
\*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
\*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],
\*.qt,*.divx,*.as[fx],*.unknown_video},
\ thu.sh -ck %c %px %py %pw %ph %pd
kitty needs a special vifm configuration that includes the "%N" macro option. Use this in your vifmrc
file,
~/.config/vifm/vifmrc
" generates state session string with esc queried values,
" for example, cell pixel width and height and maximum supported image size
let $SESS = system('thu.sh -j')
" thu.sh is called with -ck
" '-c' tells thu.sh to process %pw and %ph as cell units
" '-k' tells thu.sh to use the state state session string from the '-j' call above
fileviewer {*.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm,*.svg,*.pdf,*.epub,
\*.ttf,*.otf,*.woff,*.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,
\*.ac3,*.og[agx],*.spx,*.opus,*.aac,*.mpga,*.avi,*.mp4,
\*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
\*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],
\*.qt,*.divx,*.as[fx],*.unknown_video},
\ thu.sh -ck %c %px %py %pw %ph %pd %N
\ %pc
\ thu.sh -w %N
related,
- discussion at kitty, https://github.com/kovidgoyal/kitty/discussions/7275
- discussion at vifm, https://github.com/vifm/vifm/issues/731#issuecomment-1445124018