Created
May 14, 2012 09:59
-
-
Save insom/2693035 to your computer and use it in GitHub Desktop.
Daz-inspired .bashrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias ss="ssh $1.manc.iws-hosting.co.uk" | |
# Color codes | |
RED='\[\033[01;31m\]' | |
GREEN='\[\033[01;32m\]' | |
YELLOW='\[\033[01;33m\]' | |
BLUE='\[\033[01;34m\]' | |
PURPLE='\[\033[01;35m\]' | |
CYAN='\[\033[01;36m\]' | |
WHITE='\[\033[01;37m\]' | |
NIL='\[\033[00m\]' | |
# Hostname styles | |
FULL='\H' | |
SHORT='\h' | |
# System => color/hostname map: | |
# HC: hostname color | |
# LC: location/cwd color | |
# HD: hostname display (\h vs \H) | |
# UC: username colour | |
# Defaults: | |
HC=$YELLOW | |
LC=$BLUE | |
HD=mac | |
UC=$GREEN | |
# Manually cut hostname; hostname -s bails out on some systems. | |
case $( hostname | cut -d '.' -f 1 ) in | |
# yonah | yonah-nix | diamondville ) HC=$YELLOW LC=$GREEN HD=$SHORT ;; | |
*-production ) HC=$RED HD=$SHORT ;; | |
mail | code | www* | monitor | xen | penryn ) HC=$RED ;; | |
esac | |
# Highlight when we're a special user | |
case ${USERNAME} in | |
root | www-data ) UC=$RED ;; | |
esac | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
function __git_dirty { | |
git diff --quiet HEAD &>/dev/null | |
[ $? == 1 ] && echo "!" | |
} | |
# Prompt function because PROMPT_COMMAND is awesome | |
function set_prompt() { | |
# If logged in as another user, not gonna have all this firing anyway. | |
# So let's just show the host only and be done with it. | |
host="${HC}${HD}${NIL}" | |
# Virtualenv | |
_venv=`basename "$VIRTUAL_ENV"` | |
venv="" # need this to clear it when we leave a venv | |
if [[ -n $_venv ]]; then | |
venv=" ${NIL}{${PURPLE}${_venv}${NIL}}" | |
fi | |
# RVM | |
_rvm=`~/.rvm/bin/rvm-prompt` | |
rvm="" | |
if [[ -n $_rvm ]]; then | |
rvm=" ${NIL}{${RED}${_rvm}${NIL}}" | |
fi | |
# Git branch | |
gitbranch=" ${NIL}${RED}$(__git_dirty)${GREEN}$(parse_git_branch)${NIL}" | |
# Dollar/hash | |
end="${LC}\$ ${NIL}" | |
# Working dir | |
wd="${LC}\\w" | |
# bzr version | |
if [[ -f .bzr/branch/last-revision ]]; | |
then | |
BZRVER=`cat .bzr/branch/last-revision| awk '{print $1}'` | |
BZR=" ${RED}{bzr rev: ${BZRVER}}${NIL}" | |
else | |
BZR="" | |
fi | |
# svn version | |
if [[ -f .svn/entries ]]; | |
then | |
SVNVER=`svn info | grep Revision | awk '{print $NF}'` | |
SVN=" ${RED}{svn rev: ${SVNVER}}${NIL}" | |
else | |
SVN="" | |
fi | |
# Feels kind of like cheating...but works so well! | |
export PS1="${host}:${wd}${gitbranch}${rvm}${venv}${BZR}${SVN} ${UC}\u${end}" | |
} | |
export PROMPT_COMMAND=set_prompt | |
# Dont store commands starting with a space in the history | |
export HISTIGNORE="[ ]*" | |
alias ls="ls -F" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment