Skip to content

Instantly share code, notes, and snippets.

@junosuarez
Created November 30, 2012 22:21
Show Gist options
  • Save junosuarez/4179115 to your computer and use it in GitHub Desktop.
Save junosuarez/4179115 to your computer and use it in GitHub Desktop.
.bash_profile
export PATH=$PATH:/usr/local/sbin:~/bin:/Users/jaso/nvm/v0.8.8/bin
#alias todo=`s ~/Dropbox/todo.txt`
. ~/nvm/nvm.sh
# {{{
# Node Completion - Auto-generated, do not touch.
shopt -s progcomp
for f in $(command ls ~/.node-completion); do
f="$HOME/.node-completion/$f"
test -f "$f" && . "$f"
done
# }}}
alias dev='cd ~/dev'
alias gst='git status'
alias ls='ls -p'
function parse_git_branch {
local W="\033[1;37m"
local ref=$(git symbolic-ref HEAD 2> /dev/null)
if [[ -z $ref ]]; then
return
fi
echo -e $W"/"${ref#refs/heads/}" "
}
function parse_git_status {
local st=$(git status 2> /dev/null)
if [[ -z $st ]]; then
return
fi
local staged=false;
if [[ ! -z $(git status --porcelain | grep "^M") ]]; then
local staged=true
fi
local modified=false;
if [[ ! -z $(git status --porcelain | grep "^ M") ]]; then
local modified=true
fi
local untracked=false;
if [[ ! -z $(git status --porcelain | grep "^??") ]]; then
local untracked=true
fi
#echo .
#echo "staged "$staged
#echo "modified "$modified
#echo "untracked "$untracked
#echo .
local Y="\033[1;33m"
local G="\033[1;32m"
local R="\033[1;31m"
if $staged || $modified || $untracked; then
echo -e $Y"*"
elif [[ ! -z $(git status | tail -n 1 | grep "working directory clean") ]]; then
echo -e $G"clean"
else
echo -e $R"!"
fi
}
function get_local_dir {
echo $(expr `pwd` : '.*/\(.*\)')
}
GREY="\[\033[0;37m\]"
RED="\[\033[1;31m\]"
YELLOW="\[\033[1;33m\]"
PLAIN="\[\033[0m\]"
PS1="$GREY jden:\$(get_local_dir) \$(parse_git_branch)$PLAIN\$(parse_git_status)$PLAIN \$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment