Skip to content

Instantly share code, notes, and snippets.

@Sophrinix
Forked from tonylukasavage/.bash_profile
Created January 10, 2014 23:02
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 Sophrinix/8364372 to your computer and use it in GitHub Desktop.
Save Sophrinix/8364372 to your computer and use it in GitHub Desktop.
reset="\033[0;0m"
dir_color="\033[0;32m"
git_color="\033[2;37m"
ti_color="\033[2;36m"
alloy_color="\033[0;36m"
prompt_color=$reset
find-up() {
path=$(pwd)
while [[ "$path" != "" && ! -e "$path/$1" ]]; do
path=${path%/*}
done
if [ "$path" != "" ]
then
echo "$path"
fi
}
cecho() {
echo -en "\[$2\]$1\[$reset\]"
}
parse_git_branch() {
version=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ ! -z "$version" ]
then
cecho "--(" $reset
cecho "$version" $git_color
[[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && cecho "*" $git_color
cecho ")" $reset
fi
}
parse_alloy_version() {
version=$(alloy --version 2> /dev/null | sed -e 's/\(.*\)/\1/')
if [ ! -z "$version" ]; then
cecho " ‡ " $reset
cecho "$version" $alloy_color
fi
cecho ")" $reset
}
parse_titanium_version() {
tiapp=`find-up tiapp.xml`
if [ -z "$tiapp" ]; then return; fi
tiversion=$(cat $tiapp/tiapp.xml 2> /dev/null | sed -n 's/<sdk-version>\(.*\)<\/sdk-version>/\1/p' | tr -d ' \t\n\r\f')
if [ -z "$tiversion" ]; then return; fi
cecho "--(" $reset
cecho "$tiversion" $ti_color
parse_alloy_version
}
parse_prompt() {
cecho "≫ " $prompt_color
}
export PS1="\n($dir_color\w\[$reset\])$(parse_git_branch)$(parse_titanium_version)\n$(parse_prompt)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment