May 26, 2021

I updated my Zsh config today, just to make terminal tabs (in Kitty) show the current running process, instead of the default $SHELL. Looks much nicer!

TL;DR Add this to your .zshrc or wherever you put custom settings:

preexec() {
    # See, e.g.,
    print -Pn "\e]0;$1\a"
    # or, equivalently,
    # printf "\x1b]0;%s\x07" "$1";

precmd() {
    # Clean up terminal title (in case Neovim doesn't restore it to its initial state)
    # printf "\033]0;\a"
    # or print relevant stuff
    # (%~ current working directory; %1~ directory name only)
    print -Pn "\e]0;%1~\a"