Skip to content

Instantly share code, notes, and snippets.

@luan
Created October 4, 2011 01:10
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 luan/1260688 to your computer and use it in GitHub Desktop.
Save luan/1260688 to your computer and use it in GitHub Desktop.
BashRC
# ~/.bashrc: executed by bash(1) for non-login shells.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
fi
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# this is the old one
# export PS1='${debian_chroot:+($debian_chroot)}\[\e[0;33m\]\A\[\e[m\] \[\e[0;32m\]\u\[\e[m\]\[\e[0;37m\]@\[\e[m\]\[\e[0;36m\]\h\[\e[m\]:\w\$ '
function color {
echo "\[\033[$1m\]"
}
clos='\[\033[00m\]'
function rvmve {
echo -n "`color '1;31'`"
echo -n '`~/.rvm/bin/rvm-prompt i v g`'
echo $clos
}
function gitb {
echo '`[ -n "$(git branch 2>/dev/null)" ] && gb=$(git branch 2>/dev/null| grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\\\\\\1\\/) && echo "\[\033[1m\](\[\033[00m\]\[\033[0;35m\]$gb\[\033[00m\]\[\033[1m\])\[\033[00m\]"`'
}
clock="`color '0;33'`\A$clos"
user_host="`color '0;32'`\u`color '0;37'`@`color '0;36'`\h$clos"
path='\w'
prompt="`color '1;32'`\$$clos"
export PS1="$clock $user_host:$path `rvmve` `gitb`\n$prompt "
alias on='who | cut -f1 -d " " | sort -u'
alias grep='grep --color'
alias rm~='rm -f *~'
alias depl='git add . && git commit -a && git push && cap deploy:migrations'
alias rce='redcar 1>/dev/null 2>/dev/null'
alias rc='rce . &'
function gpush {
if [ "$1" == 'o' ]; then
o='origin'
elif [ "$1" == 'h' ]; then
o='heroku'
else
o='origin'
fi
if [ "$2" == 'd' ]; then
b='development'
elif [ "$2" == 'm' ]; then
b='master'
else
b='master'
fi
echo "git push $o $b"
git push $o $b
}
function gpull {
if [ "$1" == 'o' ]; then
o='origin'
elif [ "$1" == 'h' ]; then
o='heroku'
else
o='origin'
fi
if [ "$2" == 'd' ]; then
b='development'
elif [ "$2" == 'm' ]; then
b='master'
else
b='master'
fi
echo "git pull $o $b"
git pull $o $b
}
function cdcode {
cd "$HOME/Code/$@"
}
function cdrails {
cdcode "rails/$@"
}
function cdevent {
cdrails "event"
}
function cdshuffler {
cdrails "shuffler.$@"
}
function cdshw {
cdshuffler "web"
}
function cdshf {
cdshuffler "feedeater"
}
function cdpy {
cdcode "python/$@"
}
function cdtg {
cdpy "grape"
}
function cdgrape {
cdpy "grape"
}
export PATH=$PATH:$HOME/.bin/:$HOME/.opt/bin
export EDITOR=vim
export MOZILLA_FIVE_HOME=/usr/lib/xulrunner-1.9.2.17/
export FEEDEATER_ENV=development
# Start/Reuse SSH Agent - restart or re-use an existing agent
SSH_AGENT_CACHE=/tmp/ssh_agent_eval_`whoami`
if [ -s "${SSH_AGENT_CACHE}" ]
then
echo "Reusing existing ssh-agent"
eval `cat "${SSH_AGENT_CACHE}"`
# Check that agent still exists
kill -0 "${SSH_AGENT_PID}" 2>/dev/null
if [ $? -eq 1 ]
then
echo "ssh-agent pid ${SSH_AGENT_PID} no longer running"
# Looks like the SSH-Agent has died, it'll be restarted below
rm -f "${SSH_AGENT_CACHE}"
fi
fi
if [ ! -f "${SSH_AGENT_CACHE}" ]
then
echo "Starting new ssh-agent"
touch "${SSH_AGENT_CACHE}"
chmod 600 "${SSH_AGENT_CACHE}"
ssh-agent >> "${SSH_AGENT_CACHE}"
chmod 400 "${SSH_AGENT_CACHE}"
eval `cat "${SSH_AGENT_CACHE}"`
ssh-add ~/.ssh/id_rsa
fi
function grepo {
grep -R -n --exclude "*svn-base" "$1" *
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment