To recognize better the start and the end of output on a commandline, I want to change the color of my prompt, so that it is visibly different from the programs output. As I use zsh, can anyone give me a hint?
views:
2458answers:
2
+2
A:
Here's an example of how to set a red prompt:
PS1=$'\e[0;31m$ \e[0m'
The magic is the \e[0;31m
(turn on red foreground) and \e[0m
(turn off character attributes). These are called escape sequences. Different escape sequences give you different results, from absolute cursor positioning, to color, to being able to change the title bar of your window, and so on.
For more on escape sequences, see the wikipedia entry on ANSI escape codes
Bryan Oakley
2009-03-27 13:41:04
Thank's alot, that helps.
Mnementh
2009-03-27 15:17:44
I am using PROMPT='[%!]' in my .zshrc. How can you color it? I run unsuccessfully PROMPT='\e[0;31m[%!] \e[0m' in my .zshrc.
Masi
2009-04-29 03:22:25
If you do not wrap your *zsh* prompt escape sequences in `%{` `%}`, it can create confusing redisplay issues (e.g. when typing long commands, editing a command line, moving though history, etc.).
Chris Johnsen
2010-03-28 22:07:29
+10
A:
Put this in ~/.zshrc:
autoload -U colors && colors
PS1="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% "
fireDude67
2010-03-28 21:37:49