Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Titlebar-handling with zsh and screen



BTW, for those who are interested, here's my current code for the
terminal title:

In .screenrc:

hardstatus off
hardstatus string "%h%n (%t)"
termcapinfo xterm*|rxvt hs:ts=\E]2;:fs=^G:ds=\E]2;TITLEDISABLED^G

In .zshrc:

zmodload -i zsh/parameter

precmd()
{
  psvar[1]=$#jobstates;
  if [[ $psvar[1] -eq 0 ]] then
    psvar[1]=()
  elif [[ $psvar[1] -eq 1 ]] then
    psvar[1]="$psvar[1] job"
  else
    psvar[1]="$psvar[1] jobs"
  fi
  [[ -n $TTY && $TERM == (xterm*|dtterm|rxvt|screen*) ]] &&
    {
      print -nP "\e]1;%m:%.\x07"
      print -nP "\e]2;%(1v. %1v |.)${WINTITLE:+ $WINTITLE |} %n@%m - %~ | %y"
      [[ $TERM == screen* ]] && print -n .
      print -n "\x07"
    } > $TTY
}

TRAPCLD() { [[ -o interactive && -n $TTY ]] && precmd }

However, there's still a problem when a job terminates at the wrong
place. For instance:

$ sleep 5 &
$ screen

When the sleep terminates, the title will be (incorrectly) updated.
Moreover, I don't understand why the title doesn't come back to its
correct value when I hit the Return key.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA



Messages sorted by: Reverse Date, Date, Thread, Author