Skip to content

Instantly share code, notes, and snippets.

@stevekinney
Created August 30, 2016 02:26
Show Gist options
  • Save stevekinney/02f70bcf09848e0b471e4b51451beef4 to your computer and use it in GitHub Desktop.
Save stevekinney/02f70bcf09848e0b471e4b51451beef4 to your computer and use it in GitHub Desktop.
export NVM_DIR="/Users/stevekinney/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
export GREP_OPTIONS='--color=auto'
export CLICOLOR=1
export LESS='--quit-if-one-screen --RAW-CONTROL-CHARS --no-init --tabs=4'
export LS_COLORS=GxFxCxDxBxegedabagaced
export TREE_COLORS='di=1;36:ln=1;35:so=1;32:pi=1;33:ex=1;31:bd=34;46:cd=34;33:fi=0:or=4;31'
export LSCOLORS=$LS_COLORS
export EDITOR=mate
function nonzero_return() {
RETVAL=$?
[ $RETVAL -ne 0 ] && echo "$RETVAL"
}
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo -e "\033[m|\033[33m${BRANCH}\033[m${STAT}\033[m|\033[m"
else
echo ""
fi
}
# get current status of git repo
function parse_git_dirty {
status=`git status 2>&1 | tee`
dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`
ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`
newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`
renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`
deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`
bits=''
if [ "${renamed}" == "0" ]; then
bits="R${bits}"
fi
if [ "${ahead}" == "0" ]; then
bits="→${bits}"
fi
if [ "${newfile}" == "0" ]; then
bits="+${bits}"
fi
if [ "${untracked}" == "0" ]; then
bits="?${bits}"
fi
if [ "${deleted}" == "0" ]; then
bits="␡${bits}"
fi
if [ "${dirty}" == "0" ]; then
bits="✗${bits}"
fi
if [ ! "${bits}" == "" ]; then
echo -e " \033[31m${bits}\033[m"
else
echo -e " \033[32m✓\033[m"
fi
}
export PS1="\n\[\e[36m\]\w\[\e[m\] \`parse_git_branch\` \n\[\e[41m\]\`nonzero_return\`\[\e[m\]\[\e[32m\]→\[\e[m\] "
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
alias git="hub"
alias desk="cd ~/Desktop"
alias proj="cd ~/Projects"
alias turing="cd ~/Turing"
alias fee="cd ~/Turing/front-end-curriculum"
PATH="$PATH:$HOME/Turing/roster/bin" # Add Turing roster functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment