Created
May 24, 2011 19:33
-
-
Save mgrouchy/989495 to your computer and use it in GitHub Desktop.
bashrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the basics | |
: ${HOME=~} | |
: ${LOGNAME=$(id -un)} | |
: ${UNAME=$(uname)} | |
# complete hostnames from this file | |
: ${HOSTFILE=~/.ssh/known_hosts} | |
# readline config | |
: ${INPUTRC=~/.inputrc} | |
# ---------------------------------------------------------------------- | |
# SHELL OPTIONS | |
# ---------------------------------------------------------------------- | |
shopt -s cdspell | |
shopt -s cdable_vars | |
shopt -s checkhash | |
shopt -s checkwinsize | |
shopt -s sourcepath | |
shopt -s cmdhist | |
shopt -s extglob | |
# bring in system bashrc | |
test -r /etc/bashrc && | |
. /etc/bashrc | |
# notify of bg job completion immediately | |
set -o notify | |
# no mail checking | |
unset MAILCHECK | |
# we want the various sbins on the path along with /usr/local/bin | |
PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" | |
PATH="/usr/local/bin:$PATH" | |
# put ~/bin on PATH if you have it | |
test -d "$HOME/bin" && | |
PATH="$HOME/bin:$PATH" | |
# enable en_US locale w/ utf-8 encodings if not already configured | |
: ${LANG:="en_US.UTF-8"} | |
: ${LANGUAGE:="en"} | |
: ${LC_CTYPE:="en_US.UTF-8"} | |
: ${LC_ALL:="en_US.UTF-8"} | |
export LANG LANGUAGE LC_CTYPE LC_ALL | |
# ignore backups, CVS directories, python bytecode, vim swap files | |
FIGNORE="~:CVS:#:.pyc:.swp:.swa:apache-solr-*" | |
# history stuff | |
HISTCONTROL=ignoreboth | |
HISTFILESIZE=10000 | |
HISTSIZE=10000 | |
if [ "$UNAME" = Darwin ]; then | |
# put ports on the paths if /opt/local exists | |
test -x /opt/local -a ! -L /opt/local && { | |
PORTS=/opt/local | |
# setup the PATH and MANPATH | |
PATH="$PORTS/bin:$PORTS/sbin:$PATH" | |
MANPATH="$PORTS/share/man:$MANPATH" | |
# nice little port alias | |
alias port="sudo nice -n +18 $PORTS/bin/port" | |
} | |
test -x /usr/pkg -a ! -L /usr/pkg && { | |
PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH" | |
MANPATH="/usr/pkg/share/man:$MANPATH" | |
} | |
fi | |
# disk usage with human sizes and minimal depth | |
alias du1='du -h --max-depth=1' | |
alias fn='find . -name' | |
alias hi='history | tail -20' | |
# LS AND DIRCOLORS | |
# we always pass these to ls(1) | |
LS_COMMON="-hBG" | |
# if the dircolors utility is available, set that up to | |
dircolors="$(type -P gdircolors dircolors | head -1)" | |
test -n "$dircolors" && { | |
COLORS=/etc/DIR_COLORS | |
test -e "/etc/DIR_COLORS.$TERM" && COLORS="/etc/DIR_COLORS.$TERM" | |
test -e "$HOME/.dircolors" && COLORS="$HOME/.dircolors" | |
test ! -e "$COLORS" && COLORS= | |
eval `$dircolors --sh $COLORS` | |
} | |
unset dircolors | |
# setup the main ls alias if we've established common args | |
test -n "$LS_COMMON" && | |
alias ls="command ls $LS_COMMON" | |
# these use the ls aliases above | |
alias ll="ls -l" | |
alias l.="ls -d .*" | |
# push SSH public key to another box | |
push_ssh_cert() { | |
local _host | |
test -f ~/.ssh/id_dsa.pub || ssh-keygen -t dsa | |
for _host in "$@"; | |
do | |
echo $_host | |
ssh $_host 'cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_dsa.pub | |
done | |
} | |
function extract() # Handy Extract Program. | |
{ | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xvjf $1 ;; | |
*.tar.gz) tar xvzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) unrar x $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xvf $1 ;; | |
*.tbz2) tar xvjf $1 ;; | |
*.tgz) tar xvzf $1 ;; | |
*.zip) unzip $1 ;; | |
*.Z) uncompress $1 ;; | |
*.7z) 7z x $1 ;; | |
*) echo "'$1' cannot be extracted via >extract<" ;; | |
esac | |
else | |
echo "'$1' is not a valid file" | |
fi | |
} | |
function dropshare() | |
{ | |
cp -Rv $1 ~/Dropbox/Public/ | |
} | |
# show git information in status | |
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='\u\[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ ' | |
# vim: ts=4 sts=4 shiftwidth=4 expandtab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment