[clug] Last command exit code in your prompt string

Nemo Thorx clug at nemo.house.cx
Mon Mar 18 08:26:11 MDT 2013

On 14 Mar (a Thursday in 2013) around 0132 hours, Brendan Jurd did utter:
> A little something for your bashrc.
> PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w $(if [ $? == 0 ]; then
> echo "\[\033[01;32m\]✓"; else echo "\[\033[01;31m\]✗"; fi)
> \$\[\033[00m\] '
> I saw this on twitter (courtesy of @selenamarie) and have been using
> it the past couple of weeks.  Don't leave home without it.


I'm a huge believer in prompt customisation - after all, it's the key UI
feature for anyone living in the commandline. 

The above is probably one of my two favourite customisations that I've
seen in prompts. 

The trick I REALLY find fantastic is to colourise the $PWD differently
depending if it's a writeable folder or not.

    [[ -w $PWD ]] && pwdcol="%B%F{blue}" || pwdcol="%F{magenta}"

(and now I'm looking at that, I'm thinking I might expand it to
differentiate between "exists but RO to me" and "does not exist"!)

My prompt has many other "features" (many would consider them bloat :)
...my notes (and link to config) ...I'm always open to new ideas!



  ----------------------------------------- -----------------------------
                                                    earth native

More information about the linux mailing list