Last active
August 22, 2021 23:57
-
-
Save resilar/ade1e0311755e7e0a402cbecc836f486 to your computer and use it in GitHub Desktop.
Dynamic window title with zsh shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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