[CentralOH] 2014-09-29 會議 Scribbles 落書/惡文?

Ann Elliott elliott.222 at osu.edu
Thu Oct 9 18:54:14 CEST 2014

On Oct 8, 2014, at 9:13 PM, jep200404 at columbus.rr.com wrote:

> Jason Green
> colorized prompts (URL for such?, perhaps on https://github.com/gJigsaw???)
> Indicating success or failure of previous command in color of following prompt
> is cool. That's something I'd not heard of before.
> Jason, please post your command prompt code.

I love colorized prompts that turn red when I get a non-zero exit code! Here’s mine:

In bash, with a prompt that’s usually green:

PS1='\[\033[`if [ $? -gt 0 ]; then echo 31; else echo 32; fi`m\]\h:\w \u\$ \[\033[00m\]’

In tcsh, with a prompt that’s usually yellow:

if ($?prompt) then
	if ($?tcsh) then
		set promptchars='$#'
		set prompt='%{\033[33m%}'\[$user'@%m %?] %c2%#%{\033[00m%} '
		set prompt='\[$user@`hostname %?] -s`\\$\ '

Ann Elliott
Systems Developer/Engineer
Physics Department
The Ohio State University
elliott.222 at osu.edu

More information about the CentralOH mailing list