It’s been at the back of my mind that I could probably use some of the more advanced features of iTerm2, rather than just using it as a Visor TotalTerminal replacement (where pressing ctrl-space toggles a full-screen terminal and back again).

But after seeing this great Twitter thread: 💡FAQ about displaying stuff in a terminal from Kate I thought I’d check whether iTerm2 can display images. Ace, it can! There are two helpers; one for cat-ing images imgcat and imgls for ls-ing a folder with thumbnails.

Kate uses kitty for her terminal, which in turn uses libsixel and the Sixel graphics format originally designed for terminals and dot-matrix printers.

Another nice trick in the thread is to change your terminal prompt to red for a non-zero exit status. I’m a bash stalwart, so here’s how to do that:

export PS1="\$([ \$? -gt 0 ] && printf '\[\033[31m\]'; printf '$ \[\033[0m\]')"

It checks the exit code [ $? -gt 0 ] (you need the backslashes in the PS1 line above so $ is correctly interpolated) and if the result is non-zero, print the escape sequence for red. Then print the prompt $ followed by the escape sequence to set text back to normal (in case we’ve printed red).

I tend to rely on gnu screen to handle displaying the current folder, git branch, current screen window etc, using this .screenrc madness that I’ve cribbed from across the internet:

hardstatus string '%{= #ff0000}%{= #ffffff}%?%-Lw%?%{#ff0000}(%{#ffffff}%n%f%t%?(%u)%?%{#ff0000})%{#ffffff}%?%+Lw%?%?%= %{#00ff00}'

# https://www.gnu.org/software/screen/manual/html_node/Backtick.html
backtick 1 1 1 cat $HOME/.pwd # %1 in caption
backtick 2 1 1 $HOME/bin/cwb # %2 in caption
caption always "%1` (%2`)"

Which gives me a nice status line:

gnu-screen-status

But having that red prompt on errors is a nice touch:

imgcat and ps1