Skip to content

Instantly share code, notes, and snippets.

@nacin
Created September 13, 2012 18:41
Show Gist options
  • Save nacin/3716583 to your computer and use it in GitHub Desktop.
Save nacin/3716583 to your computer and use it in GitHub Desktop.
SVN status at the prompt
parse_svn_revision() {
local BRANCH WPVER INFO=$(svn info 2>/dev/null)
[ "$INFO" ] || return
REV=$(printf "%s\n" "$INFO" | grep Revision | sed -e 's/Revision: //')
BRANCH=$(printf "%s\n" "$INFO" | grep URL | sed -e 's/URL: //' | xargs basename)
if [ -f wp-includes/version.php ]; then
WPVER=$(grep wp_version\ = wp-includes/version.php | sed -e "s/.* '/ /" -e "s/';//")
fi
echo "$BRANCH:r$REV$WPVER"
}
svn_local_changes() {
local DIRTY
[ "$(svn st --ignore-externals | grep -v [X?])" ] && DIRTY=' * '
echo "$DIRTY"
}
export PS1="\[\e[00;31m\]\u \[\e[00m\]\[\e[00;33m\]\w \[\e[00;35m\]\$(parse_svn_revision)\[\e[00;32m\]\$(svn_local_changes)\[\e[00m\]$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment