Skip to content

Instantly share code, notes, and snippets.

@halbtuerke
Created June 30, 2009 21:34
Show Gist options
  • Save halbtuerke/138445 to your computer and use it in GitHub Desktop.
Save halbtuerke/138445 to your computer and use it in GitHub Desktop.
export PATH=/Users/patrick/Applications:/usr/local/git/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:./cake/console:/Applications/xampp/xamppfiles/htdocs/cake_1.2_rc2/cake/console:$PATH
export TERM=xterm-color
export CLICOLOR=true
export LSCOLORS=exfxcxdxbxegedabagacad
export LC_CTYPE=en_US.UTF-8
export EDITOR="mate -w"
export CVSEDITOR="mate -w"
export SVN_EDITOR="mate -w"
export PKG_CONFIG_PATH="/Library/Frameworks/Mono.framework/Versions/1.9.1/lib/pkgconfig:/opt/local/lib/pkgconfig"
export HISTCONTROL=erasedups
export HISTSIZE=10000
shopt -s histappend
bind "set completion-ignore-case on"
bind "set bell-style none"
bind "set show-all-if-ambiguous On"
alias cls="clear"
alias u="unrar x"
alias r="rtorrent"
alias l='ls -G'
alias ..='cd ..'
alias ..2="cd ../.."
alias ..3="cd ../../.."
alias ..4="cd ../../../.."
alias ..5="cd ../../../../.."
# shows the long listing
alias ll='ls -hl'
alias la='ls -a'
# shows the long listing with hidden files
alias lla='ls -lah'
alias f='find . -iname'
alias g='grep -i -n -r'
alias profileme="history | awk '{print $2}' | awk 'BEGIN{FS=\"|\"}{print $1}' | sort | uniq -c | sort -n | tail -n 20 | sort -nr"
alias top="top -o cpu"
alias ss='./script/server'
## git aliases
alias gs='git status'
alias gl='git pull'
alias gp='git push'
alias gd='git diff | mate'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gb='git branch'
alias gba='git branch -a'
alias ghn='gh network fetch & gh network commits --nocache'
##
alias inbox='cd ~/Desktop/.Inbox'
alias upbundle='cd ~/Desktop/.Inbox/TextMateBundles; svn up'
alias reload="source ~/.profile"
alias p="ping heise.de"
alias h='history|grep'
alias hhtdocs='cd /Applications/xampp/xamppfiles/htdocs'
alias systail='tail -f /var/log/system.log'
alias pubip='curl http://www.whatismyip.com/automation/n09230945.asp && echo'
alias lpath="echo \$PATH | tr : \\\\n"
alias pi="sudo port -v install"
alias x="cd ~/Coding/XCode3.1/"
##
alias java6='/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java'
alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"'
alias killmozy='sudo killall MozyBackup'
##
# DELUXE-USR-LOCAL-BIN-INSERT
# (do not remove this comment)
##
echo $PATH | grep -q -s "/usr/local/bin"
if [ $? -eq 1 ] ; then
PATH=$PATH:/usr/local/bin
export PATH
fi
function c {
cd ~/Coding/$1
}
## extract compressed files
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
export PREEXEC_EXCLUDE_LIST="mc less bash"
. ~/.preexec.bash
# called before each command and starts stopwatch
function preexec () {
export PREEXEC_CMD=`echo $1 | awk '{ print $1; }'`
export PREEXEC_TIME=$(date +'%s')
}
# called after each command, stops stopwatch
# and notifies if time elpsed exceeds threshold
function precmd () {
stop=$(date +'%s')
start=${PREEXEC_TIME:-$stop}
let elapsed=$stop-$start
max=${PREEXEC_MAX:-10}
for i in ${PREEXEC_EXCLUDE_LIST:-}; do
if [ "x$i" = "x$PREEXEC_CMD" ]; then
max=999999;
break;
fi
done
if [ $elapsed -gt $max ]; then
growlnotify -n "iTerm" -m "took $elapsed secs" ${PREEXEC_CMD:-Shell Command}
fi
}
preexec_install
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
function parse_git_branch {
git rev-parse --git-dir &> /dev/null
git_status="$(git status 2> /dev/null)"
branch_pattern="^# On branch ([^${IFS}]*)"
remote_pattern="# Your branch is (.*) of"
diverge_pattern="# Your branch and (.*) have diverged"
if [[ ! ${git_status}} =~ "working directory clean" ]]; then
state="${RED}⚡ "
fi
# add an else if or two here if you want to get more specific
if [[ ${git_status} =~ ${remote_pattern} ]]; then
if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then
remote="${YELLOW}↑"
else
remote="${YELLOW}↓"
fi
fi
if [[ ${git_status} =~ ${diverge_pattern} ]]; then
remote="${YELLOW}↕"
fi
if [[ ${git_status} =~ ${branch_pattern} ]]; then
branch=${BASH_REMATCH[1]}
echo " (${branch})${remote}${state}"
fi
}
function prompt_func() {
previous_return_value=$?;
# prompt="${TITLEBAR}$BLUE[$RED\w$GREEN$(__git_ps1)$YELLOW$(git_dirty_flag)$BLUE]$COLOR_NONE "
prompt="${TITLEBAR}${BLUE}[${RED}\$(date +%H:%M)${BLUE}]${BLUE}[${RED}\w${GREEN}$(parse_git_branch)${BLUE}]${COLOR_NONE} "
if test $previous_return_value -eq 0
then
PS1="${prompt}➔ "
else
PS1="${prompt}${RED}➔${COLOR_NONE} "
fi
}
PROMPT_COMMAND=prompt_func
# Bookmark folders
if [ ! -f ~/.dirs ]; then # if doesn't exist, create it
touch ~/.dirs
fi
alias show='cat ~/.dirs'
save (){
command sed "/!$/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ;
}
source ~/.dirs # Initialization for the above 'save' facility: source the .sdirs file
shopt -s cdable_vars # set the bash option so that no '$' is required when using the above facility
# Show a cow with some random story at startup
# fortune | cowsay -n
source ~/.bash/completions
# source ~/.git-completion.sh
__open ()
{
COMPREPLY=()
if [[ "${COMP_WORDS[$COMP_CWORD-1]}" == "-a" ]] ; then
apps=$(ps ax|egrep -o '[^/]+\.app'|sed 's/\.app$//; s/ /\\\\ /g')
local IFS=$'\n'
COMPREPLY=( $( compgen -W "$apps" -- "${COMP_WORDS[COMP_CWORD]}" ) )
fi
return 0
}
complete -o default -F __open open
gwd()
{
$*
growlnotify "${1} is done" -m '…'
}
function wman() {
url="man:${1}"
echo `open $url`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment