-
-
Save peterbsmyth/4948cdc09982947be3618ba28afa4292 to your computer and use it in GitHub Desktop.
.bashrc requires bash > 4.1 [FIXES escape bug]
This file contains hidden or 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
git="" | |
function parse_git_branch() { | |
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` | |
if [ ! "${BRANCH}" == "" ] | |
then | |
STAT=`parse_git_dirty` | |
STR=$'\u251c' | |
STR+=$'\u2574' | |
STR+="$cyan${BRANCH}${STAT}" | |
git="${STR}\n${white}" | |
# echo -e "${git}" | |
else | |
echo "" | |
fi | |
} | |
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=">${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="x${bits}" | |
fi | |
if [ "${dirty}" == "0" ]; then | |
bits="!${bits}" | |
fi | |
if [ ! "${bits}" == "" ]; then | |
echo " ${bits}" | |
else | |
echo "" | |
fi | |
} | |
# Color variable names based off 16 color terminal defaults | |
black='\[\e[0;30m\]' | |
red='\[\e[0;31m\]' | |
green='\[\e[0;32m\]' | |
yellow='\[\e[0;33m\]' | |
blue='\[\e[0;34m\]' | |
magenta='\[\e[0;35m\]' | |
cyan='\[\e[0;36m\]' | |
lightgray='\[\e[0;90m\]' | |
white='\[\e[0;97m\]' | |
parse_git_branch | |
PS1="" | |
PS1+="$white" | |
PS1+=$'\u256d' # Unicode pipe character | |
PS1+=$'\u2574' | |
PS1+="$red\u" # User | |
# PS1+="$white at " | |
# PS1+="$yellow\h" # Machine | |
PS1+="$white in " | |
PS1+="$green\w$white\n" # Current Path | |
# PS1+="\`parse_git_branch\`" | |
PS1+="${git}" | |
PS1+="$white" | |
PS1+=$'\u2570' | |
PS1+=$'\u2500' | |
# PS1+=$'\u03a3 ' # Sigma | |
PS1+=$'\u03bb ' # Lamda | |
#PS1+=$'\u203a ' | |
export PS1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment