Skip to content

Instantly share code, notes, and snippets.

@resilar
Last active August 22, 2021 23:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save resilar/ade1e0311755e7e0a402cbecc836f486 to your computer and use it in GitHub Desktop.
Save resilar/ade1e0311755e7e0a402cbecc836f486 to your computer and use it in GitHub Desktop.
Dynamic window title with zsh shell
# Dynamic window title with zsh shell.
# Shows current directory and running (multi-line) command.
case "$TERM" in (rxvt|rxvt-*|st|st-*|*xterm*|(dt|k|E)term)
local term_title () { print -n "\e]0;${(j: :q)@}\a" }
precmd () {
local DIR="$(print -P '[%c]%#')"
term_title "$DIR" "zsh"
}
preexec () {
local DIR="$(print -P '[%c]%#')"
local CMD="${(j:\n:)${(f)1}}"
term_title "$DIR" "$CMD"
}
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment