Create a gist now

Instantly share code, notes, and snippets.

ps1
find-up() {
local path=$(pwd)
while [[ "$path" != "" && ! -e "$path/$1" ]]; do
path=${path%/*}
done
if [ "$path" != "" ]
then
echo "$path"
fi
}
parse_git_branch() {
local branch=$(echo -n $(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'))
if [ ! -z "$branch" ]; then
[[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && branch="$branch*"
echo -en "--(\\033[2;37m$branch\\033[0;0m)"
fi
}
parse_alloy_version() {
local version=$(alloy --version 2> /dev/null)
if [ ! -z "$version" ]; then
echo -n ""
echo -en "\\033[0;36m$version\\033[0;0m"
fi
}
parse_titanium_version() {
local tiapp=`find-up tiapp.xml`
if [ -z "$tiapp" ]; then return; fi
local 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
echo -en "--(\\033[2;36m$tiversion\\033[0;0m"
parse_alloy_version
echo -n ")"
}
export PS1="\n(\033[0;32m\w\033[0;0m)\$(parse_git_branch)\$(parse_titanium_version)\n≫ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment