(toc auto-generated)

This is a collection of bash environment settings and useful information that I like to keep handy for when I'm setting up a new shell environment.

It's an ever-growing work in progress that I add to as I discover new customizations (and have the time to document them).

My main focus here is customizing the colors in bash prompts and in 'ls' output. I'm a fairly visual person, so I like different systems to have different colors in their prompts. It's helpful when you have several ssh sessions open across multiple machines and want to easily identify which machine you're looking at. Reboot the wrong machine once or twice and you start to appreciate the visual hints :)

Bash Color Chart

Black 0;30 Dark Gray 1;30 Blue 0;34 Light Blue 1;34 Green 0;32 Light Green 1;32 Cyan 0;36 Light Cyan 1;36 Red 0;31 Light Red 1;31 Purple 0;35 Light Purple 1;35 Brown 0;33 Yellow 1;33 Light Gray 0;37 White 1;37

Bash Prompts

Two Line Prompt

# with time export PS1='\n\[\e[31;1m\]CWD\[\e[0m\]:\[\e[36;1m\]\w\n\[\e[32;1m\]\@:\u@\h\[\e[0m\]\$ ' # without the time: export PS1='\n\[\e[31;1m\]CWD\[\e[0m\]:\[\e[36;1m\]\w\n\[\e[32;1m\]\u@\h\[\e[0m\]\$ '

black and red

export PS1='\[\033[1;31m\](\[\033[0;37m\]\u\[\033[1;31m\]@\h\[\033[1;31m\]:\[\033[1;36m\]\w\[\033[1;31m\])\[\033[1;36m\]\$ \[\033[0;37m\]' # alternate for root, same but green username: export PS1='\[\033[1;32m\](\[\033[1;32m\]\u\[\033[1;31m\]@\h\[\033[1;31m\]:\[\033[1;36m\]\w\[\033[1;32m\])\[\033[1;36m\]\$ \[\033[0;37m\]'


# ubuntu sets a pretty nice prompt by default (if you have a TERM=xterm-color (I modified the \w to be purple (35) instead of blue (34) export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;35m\]\w\[\033[00m\]\$ '

Smiley Face Prompt

# smiley face prompt: # From: CommandLineFu PS1="\`if [ \$? = 0 ]; then echo \e[33\;40m\\\^\\\_\\\^\e[0m; else echo \e[36\;40m\\\-\e[0m\\\_\e[36\;40m\\\-\e[0m; fi\` \u \w:\h) "

Window/Tab Titles for terminal emulators (works with iTerm in OS X)

# If this is an xterm set the title to user@host:dir case "$TERM" in xterm*|rxvt*) PS1="\[\e]0;\u@\h: \w\a\]$PS1" ;; *) ;; esac

This was borrowed from a standard .bashrc on Ubuntu. It's more efficient than setting $PROMPT_COMMAND and it sends the appropriate escape codes to iTerm to set the tab title.

Without this, if you ssh to a remote machine that sets a title, that title will stick around even after your ssh session has ended. Meaning you'll be back on your local machine but the tab/window title will still reflect the last remote machine you were logged in to. Confusing...

Dir Colors


# LS_COLORS (make directories purple instead of dark blue . The rest are what ubuntu shipped w/by default) LS_COLORS='no=00:fi=00:di=01;35:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.flac=01;35:*.mp3=01;35:*.mpc=01;35:*.ogg=01;35:*.wav=01;35:'; export LS_COLORS
#0 = default colour #1 = bold #4 = underlined #5 = flashing text #7 = reverse field #31 = red #32 = green #33 = orange #34 = blue #35 = purple #36 = cyan #37 = grey #40 = black background #41 = red background #42 = green background #43 = orange background #44 = blue background #45 = purple background #46 = cyan background #47 = grey background #90 = dark grey #91 = light red #92 = light green #93 = yellow #94 = light blue #95 = light purple #96 = turquoise #100 = dark grey background #101 = light red background #102 = light green background #103 = yellow background #104 = light blue background #105 = light purple background #106 = turquoise background

Mac OS X (BSD)

# Dir colors (barwin custom) # http://www.mactips.org/archives/2005/08/02/color-your-os-x-command-prompt/ # http://www.macosxhints.com/article.php?story=20031025162727485 export CLICOLOR=1 export LSCOLORS=FxFxCxDxBxegedabagacad


alias ll='ls -la' alias cd..='cd ..' alias vi=vim alias svi='sudo vi' alias vis='vim "+set si"' alias apt-get="sudo apt-get" alias rm='rm -i' alias mv='mv -i' alias cp='cp -i' alias sha1='openssl sha1' alias grep='grep --color=auto'

Git Config

[color] diff = auto status = auto branch = auto [user] name = Your Name email = your@email.com [alias] st = status lg = log -p dc = diff --cached lol = log --graph --decorate --pretty=oneline --abbrev-commit lola = log --graph --decorate --pretty=oneline --abbrev-commit --all ls = ls-files compactlog = log --pretty=format:"%h%x09%an%x09%ad%x09%s" --date=short co = checkout

Valid XHTML 1.0 Transitional

Valid CSS!