Source

dotfiles / bash / .bashrc

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# User specific aliases and functions
# bash completion for rebar

_rebar()
{
    local cur prev sopts lopts cmdsnvars
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    sopts="-h -v -f -j"
    lopts=" --help --verbose --force --jobs="
    cmdsnvars="analyze build_plt check_plt clean compile \
        create-app create-mod create-node \
        eunit generate int_test perf_test test \
        appid= case= force=1 jobs= modid= \
        suite= verbose=1 appid="

    if [[ ${cur} == --* ]] ; then
        COMPREPLY=( $(compgen -W "${lopts}" -- ${cur}) )
    elif [[ ${cur} == -* ]] ; then
        COMPREPLY=( $(compgen -W "${sopts}" -- ${cur}) )
    else
        COMPREPLY=( $(compgen -W "${cmdsnvars}" -- ${cur}) )
    fi

    if [ -n "$COMPREPLY" ] ; then
        # append space if matched
        COMPREPLY="${COMPREPLY} "
        # remove trailing space after equal sign
        COMPREPLY=${COMPREPLY/%= /=}
    fi
    return 0
}
complete -o nospace -F _rebar rebar

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh

hg_ps1() {
    hg prompt "{hg: {branch}}{ {status}}" 2> /dev/null | sed -e "s/\(.*\)/\n\1/"
}

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/* \(.*\)/\ngit: \1$(parse_git_dirty)/"
}

export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;37m\]\u@\h\[\033[00m\]\[\033[00;35m\] \w$(parse_git_branch)$(hg_ps1) \$\[\033[00m\] '

# ALIASES

source ~/bin/git-completion.bash
source ~/.git-flow-completion.sh

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

# path stuff
PATH=~/bin:/var/lib/gems/1.8/bin:$PATH
export PATH

/usr/bin/keychain -Q -q $HOME/.ssh/id_rsa < /dev/null
[ -f $HOME/.keychain/$HOSTNAME-sh ] && source $HOME/.keychain/$HOSTNAME-sh