Noah L. Meyerhans wrote:
> The weird thing is that in zsh, I can't get the $TERM conditionals to
> have any effect. precmd() always ends up printing the escape sequence,
> even if I'm at the console. This results in an annoying beep. If I log
> in on the console, I end up manually running 'precmd(){}' to redefine
> precmd to be an empty function.
I have no trouble with it on different sorts of terminals. Here's my zsh
prompt setup.
# Prompt {{{1
# The extraprompt thing can be set when I have chroots and I want to keep
# track of which I am in.
if [ ! -e /etc/zsh.extraprompt ]; then
baseprompt="%n@%m:%~"
else
baseprompt="%n@%m(`cat /etc/zsh.extraprompt`):%~"
fi
# The prompt shows up in xterm titles too.
case $TERM in
xterm|color_xterm)
# Beware: next line has embedded raw control characters..
PROMPT="%{]0;$baseprompt%}$baseprompt>"
# Before each command is run, throw the command line up into the
# titlebar! (The only problem is that very quick commands flicker..)
preexec () {
print -nP '\033]0;%n@%m: ';
# Truncate at 60 chars, escape %, escape invisibles
print -nPR "%60>...>${(V)1//\%/%%}";
print -n '\007';
}
;;
screen*)
# Screen has a 20 character limit on title length.
PROMPT="%{k%n@%m\\%}$baseprompt>"
preexec () {
print -nP '\033k%n@%m: ';
# Truncate at 60 chars, escape %, escape invisibles
print -nPR "%60>...>${(V)1//\%/%%}";
print -n '\033\\';
}
;;
*) PROMPT="$baseprompt>"
;;
esac
unset baseprompt
# embolden root prompt
[[ UID -eq 0 ]] && PROMPT=${PROMPT/\}%n/\}%U%n%u}
Attachment:
pgpWz_hhGnWQg.pgp
Description: PGP signature