screen+zsh

~/.zshrc文件中加入如下内容:

  1. #screen integration to set caption bar dynamically
  2. function title {
  3. if [[ $TERM == "screen" || $TERM == "screen.linux" ]]; then
  4. # Use these two for GNU Screen:
  5. print -nR $'\033k'$1$'\033'\\\
  6. print -nR $'\033]0;'$2$'\a'
  7. elif [[ $TERM == "xterm" || $TERM == "urxvt" ]]; then
  8. # Use this one instead for XTerms:
  9. print -nR $'\033]0;'$*$'\a'
  10. #trap 'echo -ne "\e]0;$USER@$HOSTNAME: $BASH_COMMAND\007"' DEBUG
  11. fi
  12. }
  13. #set screen title if not connected remotely
  14. function precmd {
  15. title "`print -Pn "%~" | sed "s:\([~/][^/]*\)/.*/:\1...:"`" "$TERM $PWD"
  16. echo -ne '\033[?17;0;127c'
  17. }
  18. function preexec {
  19. emulate -L zsh
  20. local -a cmd; cmd=(${(z)1})
  21. if [[ $cmd[1]:t == "ssh" ]]; then
  22. title "@"$cmd[2] "$TERM $cmd"
  23. elif [[ $cmd[1]:t == "sudo" ]]; then
  24. title "#"$cmd[2]:t "$TERM $cmd[3,-1]"
  25. elif [[ $cmd[1]:t == "for" ]]; then
  26. title "()"$cmd[7] "$TERM $cmd"
  27. elif [[ $cmd[1]:t == "svn" ]]; then
  28. title "$cmd[1,2]" "$TERM $cmd"
  29. else
  30. title $cmd[1]:t "$TERM $cmd[2,-1]"
  31. fi
  32. }

~/.screenrc文件中加入如下内容:

  1. hardstatus alwayslastline "%{=b}%{-b}%{R}[%{=b B}%-w%{=b BK}%>%n %t%{-}%+w%{-b}%< %=%{R}][%{-b}%{M}%m-%d %D %{G}%c%{R}]"