SHOST=`print -P %m` # strip control chars and replace with "." # result is returned in $reply function _strip() { local i=1 reply=$1 while (( i <= $#1 )) ; do [[ $reply[i] > "" && $reply[i] < "" ]] || reply[i]="." (( i ++ )) done } if [[ $+WINDOW = 1 && $TERM = screen* ]] ; then PROMPT="(%n@$SHOST.$WINDOW) %B%/>%(#/#/)%b " RPROMPT="%t %D{%m/%d} %l" # set window title to first 10 chars of command # set hardstatus to hostname and first 100 chars of command preexec () { _strip $1 ; echo -En "k${reply[1,10]:gs/ /_/}\\]0;$SHOST: ${reply[1,100]}" } else PROMPT="(%n@%m) %B%/>%(#/#/)%b " case $TERM in cons25-crt|xterm*|screen*) # set titlebar to first 100 chars of command preexec () { _strip $1 ; echo -En "]0;$SHOST: $reply[1,100]" } ;; esac fi # Update titlebar and inform the user of background jobs precmd () { if [[ $+WINDOW = 1 && $TERM = screen* ]] ; then # Set the window title to $SHELL # Set hardstatus to hostname print -Pn "k${SHELL:t}\\\\]0;%m" fi case $TERM in # set titlebar to hostname cons25-crt|xterm*|screen*) print -Pn "]0;%m" ;; esac if [[ -o interactive ]] ; then jobs -s : fi }