Skip to content

Instantly share code, notes, and snippets.

@bastos
Created March 31, 2009 13:55
Show Gist options
  • Save bastos/88202 to your computer and use it in GitHub Desktop.
Save bastos/88202 to your computer and use it in GitHub Desktop.
# do not make noise
set bell-style none
export PATH=~/.gem/ruby/1.8/bin/:$PATH
# Mysql
alias mysqlstart='sudo /opt/local/bin/mysqld_safe5 &'
alias mysqlstop='/opt/local/bin/mysqladmin5 -u root -p shutdown'
# http://pastebin.com/f7a69dcd7
function tvim() {
gvim --servername `gvim --serverlist | head -1` --remote-tab "$@";
}
# always use utf-8
export LC_CTYPE=en_US.UTF-8
# editors
export SVN_EDITOR='mate -w'
export EDITOR='mate -w'
#### JAVA
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
#### History stuff
export HISTCONTROL=erasedups # don't store duplicates
export HISTSIZE=10000 # more history pls
shopt -s histappend # make sure history is saved when session ends
#### Aliases
# for editing / reloading profile
alias eprof="mate ~/.bash_profile"
alias reload="source ~/.bash_profile"
# remove all .svn directories from where we are
alias svnclean="find . -iname '.svn' | xargs rm -rf"
# source control
alias gac="git add . && git commit -a -m"
alias sup="svn up"
# lazy rails / merb commands
alias ss="./script/server"
alias sc="./script/console"
alias mig="rake db:migrate"
alias mat="merb -a thin"
# misc
alias m="mate ."
alias c="clear"
alias h="history"
alias hgrep="history | grep"
alias flushdns="dscacheutil -flushcache"
alias ll="ls -al"
#### set tab title to working directory
function set_window_and_tab_title
{
local title="$1"
if [[ -z "$title" ]]; then
title="root"
fi
local tmpdir=~/Library/Caches/${FUNCNAME}_temp
local cmdfile="$tmpdir/$title"
# Set window title
echo -n -e "\e]0;${title}\a"
# Set tab title
if [[ -n ${CURRENT_TAB_TITLE_PID:+1} ]]; then
kill $CURRENT_TAB_TITLE_PID
fi
mkdir -p $tmpdir
ln /bin/sleep "$cmdfile"
"$cmdfile" 10 &
CURRENT_TAB_TITLE_PID=$(jobs -x echo %+)
disown %+
kill -STOP $CURRENT_TAB_TITLE_PID
command rm -f "$cmdfile"
}
PROMPT_COMMAND='set_window_and_tab_title "${PWD##*/}"'
#### put git branch & status in prompt
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\]"
GRAY="\[\033[1;30m\]"
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)]/"
}
export PS1="${GREEN}\w${YELLOW}$(parse_git_branch)${COLOR_NONE}$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment