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!)

Pretty PS1 Prompt for Bash (See related posts)

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" ]
        if [ `/usr/bin/whoami` = 'root' ]
                export PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]'
                export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'

Updated: It's now more concise and functionally more sensible.

You need to create an account or log in to post comments to this site.

Related Posts