Skip to content

Customize the bash prompt

http://ubuntuforums.org/showthread.php?t=614743

cd ~/
cp .bashrc .bashrc-backup
touch .bash_colors
gedit .bash_colors

Paste in:

# ANSI color codes
RS="\[\033[0m\]"    # reset
HC="\[\033[1m\]"    # hicolor
UL="\[\033[4m\]"    # underline
INV="\[\033[7m\]"   # inverse background and foreground
FBLK="\[\033[30m\]" # foreground black
FRED="\[\033[31m\]" # foreground red
FGRN="\[\033[32m\]" # foreground green
FYEL="\[\033[33m\]" # foreground yellow
FBLE="\[\033[34m\]" # foreground blue
FMAG="\[\033[35m\]" # foreground magenta
FCYN="\[\033[36m\]" # foreground cyan
FWHT="\[\033[37m\]" # foreground white
BBLK="\[\033[40m\]" # background black
BRED="\[\033[41m\]" # background red
BGRN="\[\033[42m\]" # background green
BYEL="\[\033[43m\]" # background yellow
BBLE="\[\033[44m\]" # background blue
BMAG="\[\033[45m\]" # background magenta
BCYN="\[\033[46m\]" # background cyan
BWHT="\[\033[47m\]" # background white

Save the file, close gedit

sudo gedit .bashrc

At the bottom of the file,  add:

PS1="$HC$FGRN[$FRED\u$FGRN: $FRED\w$FGRN]\\$ $RS"
PS2="> "

source ~/.bash_colors
PS1 will look like this: [kyle: ~/Desktop]$ 

PS2 will look like a standard >,  nothing special

Here’s what the bottom of my .bashrc looks like – everything has simply been added after the standard ubuntu configuration and has worked well so far.

# load extra source files
source ~/.bash_aliases    # customized alias list
source ~/.bash_colors     # ANSI color codes

# personal prompts
PS1="$HC$FGRN[$FRED\u$FGRN: $FRED\w$FGRN]\\$ $RS"
PS2="> "
Like? Distro it!
  • Print this article!
  • Twitter
  • E-mail this story to a friend!
  • Reddit
  • del.icio.us
  • Facebook
  • Digg
  • Google Bookmarks
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Slashdot

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*