Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Michael Kohl 馃嚘馃嚬馃嚬馃嚟
@citizen428@chaos.social  路  activity timestamp 2 weeks ago

Consistently being able to quickly output an image in the terminal turns out to be a major headache for people who use different terminal emulators on different systems. This zsh function is my current best attempt (code in alt text).

#terminal #productivity

A screenshot of the following ZSH function:

function imgcat() {
  if [[ -n "$KITTY_OS" ]]; then
    # https://sw.kovidgoyal.net/kitty/kittens/icat/
    kitten icat "$1"
  elif [[ -n "$WEZTERM_PANE" ]]; then
    # https://wezterm.org/imgcat.html
    wezterm imgcat "$1"
  elif [[ -n "$ITERM_SESSION_ID" ]]; then
    # https://iterm2.com/documentation-images.html, through timg
    timg -pi "$1"
  elif [[ -n "$GHOSTTY_RESOURCES_DIR" ]]; then
    # Ghostty uses Kitty's protocol, which timg can output
    timg -pk "$1"
  else
    # If all else fails, try sixel
    timg -ps "$1"
  fi
}
A screenshot of the following ZSH function: function imgcat() { if [[ -n "$KITTY_OS" ]]; then # https://sw.kovidgoyal.net/kitty/kittens/icat/ kitten icat "$1" elif [[ -n "$WEZTERM_PANE" ]]; then # https://wezterm.org/imgcat.html wezterm imgcat "$1" elif [[ -n "$ITERM_SESSION_ID" ]]; then # https://iterm2.com/documentation-images.html, through timg timg -pi "$1" elif [[ -n "$GHOSTTY_RESOURCES_DIR" ]]; then # Ghostty uses Kitty's protocol, which timg can output timg -pk "$1" else # If all else fails, try sixel timg -ps "$1" fi }
A screenshot of the following ZSH function: function imgcat() { if [[ -n "$KITTY_OS" ]]; then # https://sw.kovidgoyal.net/kitty/kittens/icat/ kitten icat "$1" elif [[ -n "$WEZTERM_PANE" ]]; then # https://wezterm.org/imgcat.html wezterm imgcat "$1" elif [[ -n "$ITERM_SESSION_ID" ]]; then # https://iterm2.com/documentation-images.html, through timg timg -pi "$1" elif [[ -n "$GHOSTTY_RESOURCES_DIR" ]]; then # Ghostty uses Kitty's protocol, which timg can output timg -pk "$1" else # If all else fails, try sixel timg -ps "$1" fi }
  • Copy link
  • Flag this post
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About 路 Code of conduct 路 Privacy 路 Users 路 Instances
Bonfire social 路 1.0.0 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login