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.

有帮助吗?

解决方案 2

Might be an overkilled solution but installing oh-my-zsh and using its default configuration gives me a dynamic window title. See the following screenshot as an example:

enter image description here

其他提示

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top