How can I set the window title of Urxvt to the currently running (interactive) command in Zsh shell?
For instance, if I am running journalctl
, I want journalctl
to be displayed as the window title. Currently the window title is just showing urxvt
, which is fine if I am running no commands.
This is possible with the precmd and preexec hooks. I use this for my xterm. It might work unmodified. If not, the place to tweak is the escape sequence to set the terminal title, here ESC, ], 0, ;.
case $TERM in
(*xterm* | rxvt)
# Write some info to terminal title.
# This is seen when the shell prompts for input.
function precmd {
print -Pn "\e]0;zsh%L %(1j,%j job%(2j|s|); ,)%~\a"
}
# Write command and args to terminal title.
# This is seen while the shell waits for a command to complete.
function preexec {
printf "\033]0;%s\a" "$1"
}
;;
esac
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With