문제

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