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

Re: color prompt



In the last episode (Dec 05), Matt Garman said:
> In the mean time, I tried putting something like this in my ~/.zshrc file:
> 
> fg_black="$(echo -n '\e[1;30m')"
> fg_green="$(echo -n '\e[0;32m')"
> fg_brown="$(echo -n '\e[0;33m')"
> fg_grey="$(echo -n '\e[0;37m')"
> PS1="${fg_black}[${fg_green}%W %T${fg_black}] \
>         ${fg_brown}%m${fg_black}:${fg_brown}%l \
> 	${fg_black}:${fg_brown}%~${fg_grey}%# "
> 
> (that's all on one line)
> 
> Which makes my prompt look exactly the way I want it.  However, this
> seems to disturb cursor positioning for doing completions with tab and
> also browsing the command history with the arrow keys.  

Zsh expects that every character in PS1 will advance the cursor one
space.  Wrap any non-printing escape sequences in %{...%}, and it
should work.  So use %{$fg_black%}, etc.

-- 
	Dan Nelson
	dnelson@xxxxxxxxxxxx



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