Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Nick Stenning

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

Pretty PS1 Prompt for Bash

This is just a simple colored bash prompt which differentiates nicely between normal and root users.

To use this put it in ~/.bashrc, or for it to apply systemwide, in /etc/profile

if [ "$TERM" != 'dumb' ] && [ -n "$BASH" ] && [ -n "$PS1" ]
then
        if [ `/usr/bin/whoami` = 'root' ]
        then
                export PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]'
        else
                export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
        fi
fi

Updated: It's now more concise and functionally more sensible.
« Newer Snippets
Older Snippets »
1 total  XML / RSS feed