Skip to content

Instantly share code, notes, and snippets.

@oblique63
Created December 8, 2011 12:54
Show Gist options
  • Save oblique63/1446920 to your computer and use it in GitHub Desktop.
Save oblique63/1446920 to your computer and use it in GitHub Desktop.
my .profile
# Shorten lengthy paths
PROMPT_COMMAND='DIR=`pwd|sed -e "s!$HOME!~!"`; if [ ${#DIR} -gt 30 ]; then CurDir=${DIR:0:12}...${DIR:${#DIR}-15}; else CurDir=$DIR; fi'
# Git status in prompt
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ [\1$(parse_git_dirty)]/"
}
PURPLE="\[\033[0;35m\]"
# Color prompt
if [ $USER = root ]; then
PS1="\[\033[1;31m\][\u:\$CurDir]$PURPLE\$(parse_git_branch)\$\[\033[0m\] "
else
PS1="\[\033[01;32m\]\u:\[\033[00m\]\[\033[01;34m\]\$CurDir$PURPLE\$(parse_git_branch)\[\033[00m\]\[\033[1;32m\]\$\[\033[m\] "
fi
export CLICOLOR=1
export CDPATH=".:~:~/Code"
shopt -s cdspell
alias clr="clear"
alias prev="!!"
alias py="bpython"
alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs -nw"
alias untar="tar xvzf"
alias ssh-key="cat ~/.ssh/id_rsa.pub"
# Navigation
alias la='ls -a'
alias ll='ls -l'
alias lla='ls -la'
alias lsp="ls -ABgoh"
alias up="cd .."
alias up2="cd ../.."
alias up3="cd ../../.."
alias up4="cd ../../../.."
alias desk="cd ~/Desktop"
alias back="cd -"
backto() {
current_path=`pwd`
match_length=`expr $current_path : .*$1`
if [ $match_length -eq 0 ]; then
echo "No such directory in your current path:" $1
else
destination=${current_path:0:match_length}
if [ $2 ]; then
destination=$destination"/"$2
fi
echo $destination
cd $destination
fi
}
# Nonsense
alias fuck="killall"
alias bitch="sudo"
alias moar="more"
# Meta
alias edit-profile="nano ~/.profile && source ~/.profile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment