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

Misterous bug with %(# ...



Hello :) (first scuse for my poor english)

Reading the zsh's man, I see a function that interest me a lot :
%(x.true text.false text)

I'm using it for jobs, and for $?. It's working very good.

I wanted to change the prompt color if I'm logged as root. So I put
this in my zshrc :

host_color=%(#.magenta.green)

And after I'm using the host_color for coloration (You can see the
full zshrc at the end of mail) :

host="%{$fg[$host_color]%}(%m)"
warninfo="%{$fg[$host_color]%}^^ ROOT ^^ "

But the color for $host is always black, I don't know why.

When I do a echo $host, I have this :
%(#.magenta.cyan)
It seem to be good.

Maybe somebody already have this error ?

Thanks
Beber

The full zshrc :

# /etc/zsh/zprofile
# $Header: /var/cvsroot/gentoo-x86/app-shells/zsh/files/zprofile,v 1.1
2003/07/23 17:48:19 usata Exp $

[[ -e "/etc/profile.env" ]] && source /etc/profile.env

#077 would be more secure, but 022 is generally quite realistic
umask 022

if [[ "$USER" == root ]]; then
        export PATH="/bin:/sbin:/usr/bin:/usr/sbin:${ROOTPATH}:/${HOME}/bin:/usr/share/bin"
else
        export PATH="/bin:/usr/bin:${PATH}:/${HOME}/bin:/usr/share/bin"
fi
unset ROOTPATH

# Alias
alias l="ls --color=auto"
alias ls="ls --color=auto"
alias la="ls --color=auto -a"
alias lh="ls --color=auto -lh"
alias ll="ls --color=auto -l"
alias lha="ls --color=auto -lha"

# List only file beginning with "."
alias lsa="ls -ld .*"

# List only directories and symbolic
# links that point to directories
alias lsd="ls -ld *(-/DN)"

alias \.="pwd"
alias \.\.="cd .."
alias mp="mplayer"
alias j="jobs"
alias v="vim"

# Global aliases -- These do not have to be
# at the beginning of the command line.
alias -g M='| more'
alias -g H='| head'
alias -g T='| tail'
alias -g L='| less'
alias -g C='| cat'


# Alias selon compte
case $USER in
        root)
                alias distccmon="DISTCC_DIR=/var/tmp/portage/.distcc
distccmon-gnome"
                ;;
        beber)
                alias modprobe="sudo /sbin/modprobe"
                alias rmmod="sudo /sbin/rmmod"
                alias halt="sudo /sbin/halt"
                alias reboot="sudo /sbin/reboot"
                ;;
        *)
                alias mv="mv -i"
                ;;
esac

# Completion emerge
autoload -U compinit promptinit
compinit
promptinit;

# Colorisation du shell
autoload -U colors
colors

host_color=%(#.magenta.green)
echo $host_color
path_color="cyan"
date_color="blue"

date_format="%d/%m %T"
date="%{$fg[$date_color]%}%D{$date_format}"

jobs="%1(j.%j .)"
ret="%0(?..:( )"

case $USER in
        root)
                #host_color="magenta"
                host="%{$fg[$host_color]%}(%m)"
                warninfo="%{$fg[$host_color]%}^^ ROOT ^^ "
                ;;
        *)
                host="%{$fg[$host_color]%}(%n@%m)"
                ;;
esac

cpath="%{$fg[$path_color]%}%~"
end="%{$reset_color%}"

PS1="$jobs$warninfo$cpath$end $ret%# "
RPS1="$host $date$end"

# Aide
#unalias run-help
#autoload run-help

# Cache de completion
zstyle ':completion::complete:*' use-cache 1
#zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST

# history settings
HISTFILE=~/.zshhistory
HISTSIZE=3000
SAVEHIST=3000

# Bindkeys
bindkey "^A" beginning-of-line
bindkey "^E" end-of-line
bindkey "^X" delete-char
bindkey "^W" delete-word
bindkey -v                              # vi key bindings
bindkey "^V" vi-cmd-mode

# Exports
export VISUAL=/usr/bin/vim
export EDITOR=/usr/bin/vim

# Mail
export MAIL=~/Maildir
export MAILCHECK=60

# Afficher les nouvelles connections
case $USER in
        root|beber)
                watch=( $(< /etc/passwd | cut -d ':' -f 1) )
                #watch=(notme)                  # watch for everybody but me
                LOGCHECK=60                     # check every 1 min
for login/logout activity
                WATCHFMT='%n %a %l from %M at %T.'
                ;;
esac

# Options de correction
setopt  correct correctall #mailwarning



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