Skip to content

Instantly share code, notes, and snippets.

@sdball
Created October 7, 2010 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdball/615080 to your computer and use it in GitHub Desktop.
Save sdball/615080 to your computer and use it in GitHub Desktop.
bash_profile
# add "[git]" to the prompt if in a git directory
# example (normal dir):
# user@host:/PATH
# $
# (in git directory)
# user@host:/PATH/GIT/PROJECT
# [git]$
export PROMPT_COMMAND='_GIT_LABEL= ;[ -d ".git" ] && _GIT_LABEL="[git]"'
export PS1="\u@\h:\w\n\${_GIT_LABEL}\$ "
# we should always be respectful of the server
alias please="sudo"
alias pleaseedit="sudoedit"
# but being silly has its place too
alias nomnomnom="rm"
alias omnomnomnom="rm -rf"
# jump back home with a clear screen
alias cdc="cd;clear"
# svn quicklist
alias sc="svn co"
alias ss="svn status"
alias sd="svn diff"
alias sl="svn log"
alias sup="svn update"
alias sl1="svn log --limit 1"
alias sl2="svn log --limit 2"
# switched to being primarily a ruby dev from python
alias p="echo 'You probably meant r.'"
alias r="ruby"
# here's a weird one
# it creates a space for a quick note, stop with ctrl-d
# from Chris's Wiki: http://utcc.utoronto.ca/~cks/space/blog/sysadmin/CatDevNull
alias n="cat >/dev/null"
# ever want to quickly/easily
# 1. import a python module
# 2. and instantiate an object from that model
# in python's interactive mode?
# usage: pi module object
pi() { python -i -c "from $1 import *; obj=$2"; }
# create a directory and cd into it, all in one
mkcd() { mkdir -p $1 && cd $1; }
# for some reason I can never remember the proper order of arguments for cal
# this function does it for me
cal() {
if [[ $1 && $2 ]]; then
/usr/bin/cal $1 $2 2> /dev/null
if [ "$?" -ne "0" ]; then
/usr/bin/cal $2 $1
fi
else
/usr/bin/cal $1
fi
}
# find a file with ack, open in vim
vack() { vim $(ack -g $1); }
# easily serve up a directory over the web with python
serve() { python -m SimpleHTTPServer ${1:-8080}; }
##########
# OSX only
##########
# activate quicklook from the command line
alias ql="qlmanage -p 2> /dev/null"
# nice man pages
pman() { man -t $@ | ps2pdf - - | open -f -a /Applications/Preview.app; }
tman() { MANWIDTH=80 MANPAGER='col -bx' man $@ | open -f -a /Applications/TextMate.app; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment