Skip to content

Instantly share code, notes, and snippets.

@whatadewitt
Created May 16, 2013 20:17
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 whatadewitt/5594747 to your computer and use it in GitHub Desktop.
Save whatadewitt/5594747 to your computer and use it in GitHub Desktop.
my bash profile
# wp-cli
alias wp='~/git/wp-cli/bin/wp'
source ~/git/wp-cli/utils/wp-completion.bash
export WP_CLI_PHP=/Applications/MAMP/bin/php/php5.4.10/bin/php
export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
# get git branch
#function parse_git_branch {
# git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/'
#}
function parse_git_branch {
git rev-parse --git-dir > /dev/null 2>&1
if [ $? -eq 0 ]; then
git_status="$(git status 2> /dev/null)"
branch_pattern="^# On branch ([^${IFS}]*)"
detached_branch_pattern="# Not currently on any branch"
remote_pattern="# Your branch is (.*) of"
diverge_pattern="# Your branch and (.*) have diverged"
untracked_pattern="# Untracked files:"
new_pattern="new file:"
not_staged_pattern="Changes not staged for commit"
ready_to_commit_pattern="Changes to be committed"
#files not staged for commit
if [[ ${git_status}} =~ ${not_staged_pattern} ]]; then
state="${YELLOW}*"
elif [[ ${git_status}} =~ ${ready_to_commit_pattern} ]]; then
state="${GREEN}*"
fi
# add an else if or two here if you want to get more specific
# show if we're ahead or behind HEAD
# if [[ ${git_status} =~ ${remote_pattern} ]]; then
# if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then
# remote="↑"
# else
# remote="↓"
# fi
# fi
#new files
# if [[ ${git_status} =~ ${new_pattern} ]]; then
# remote="+"
# fi
#untracked files
# if [[ ${git_status} =~ ${untracked_pattern} ]]; then
# remote="✖"
# fi
#diverged branch
# if [[ ${git_status} =~ ${diverge_pattern} ]]; then
# remote="↕"
# fi
#branch name
if [[ ${git_status} =~ ${branch_pattern} ]]; then
branch=${BASH_REMATCH[1]}
#detached branch
elif [[ ${git_status} =~ ${detached_branch_pattern} ]]; then
branch="NO BRANCH"
fi
echo " ${LIME_YELLOW}(${branch}${state}${LIME_YELLOW})${NORMAL}"
fi
return
}
# git auto completion
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
# enable git unstaged indicators - set to a non-empty value
GIT_PS1_SHOWDIRTYSTATE="."
# enable showing of untracked files - set to a non-empty value
GIT_PS1_SHOWUNTRACKEDFILES="."
# enable stash checking - set to a non-empty value
GIT_PS1_SHOWSTASHSTATE="."
# enable showing of HEAD vs its upstream
GIT_PS1_SHOWUPSTREAM="auto"
BLACK=$(tput setaf 0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
LIME_YELLOW=$(tput setaf 190)
POWDER_BLUE=$(tput setaf 153)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
BRIGHT=$(tput bold)
NORMAL=$(tput sgr0)
BLINK=$(tput blink)
REVERSE=$(tput smso)
UNDERLINE=$(tput smul)
# PS1 = 'dew $';
FACE=""
#FACE="${GREEN}:D${NORMAL}";
function status_face() {
if [ $? = 0 ]; then
# export FACE="${GREEN}:D${NORMAL}";
export FACE="😃 ";
echo $FACE;
else
# export FACE="${RED}:(${NORMAL}";
export FACE="😡 ";
echo $FACE;
fi
}
PS1='\[$(status_face)\] \[${BRIGHT}\]dew\[${NORMAL}\] @ \W$(parse_git_branch)\n\[${NORMAL}\]\$ '
if [[ $(date +%u) -eq 5 ]]
then
export BEER="🍺 " # two spaces at the end because Emoji is weird
export PS1="$BEER$PS1"
fi
#export PS1='\[$(status_face)\] $PS1'
#export PS1='$PS1$(parse_git_branch)\n\[${NORMAL}\]\$ '
# PS1='\[$(status_face)\] \[${BRIGHT}\]dew\[${NORMAL}\] @ \W$(parse_git_branch)\n\[${NORMAL}\]\$ '
##
# Your previous /Users/ldewitt/.bash_profile file was backed up as /Users/ldewitt/.bash_profile.macports-saved_2013-04-02_at_14:22:22
##
# MacPorts Installer addition on 2013-04-02_at_14:22:22: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment