Skip to content

Instantly share code, notes, and snippets.

@jmoz
Created August 19, 2009 09:46
Show Gist options
  • Save jmoz/170265 to your computer and use it in GitHub Desktop.
Save jmoz/170265 to your computer and use it in GitHub Desktop.
cooler prompt
# grab the part of the repo url we want to display
svn_info() {
svn info 2> /dev/null | sed -n 's/^URL: svn:\/\/subversion\/symfony\/\(.*\)$/\1/p'
}
# Only echo if in an svn repo.
in_svn_repo() {
if [[ -d "./.svn" ]]; then
echo -e "\e[37;1mon \e[34;1m$(svn_info)"
fi
}
# Cooler prompt, orig below
#export PS1="\[\033[01;37m\][\[\033[01;32m\]\u@\h\[\033[01;37m\]:\[\033[01;34m\]\w\[\033[01;37m\]] # \[\033[00m\]"
export PS1='\[\e[1;31m\]\u \[\e[37;1m\]on \[\e[35;1m\]\h \[\e[37;1m\]in \[\e[36;1m\]\w $(in_svn_repo)\n\[\e[37;1m\] \$ \[\e[0m\]'
##############
# UBUNTU
##############
in_svn_repo() {
[[ `svn info 2> /dev/null` ]] && echo 'on '
}
svn_info() {
svn info 2> /dev/null | awk '/URL: svn:\/\/subversion\/symfony(.+)/ { print $2 }'
}
# Check for the .git directory so we know we're in a git repo, then call git_branch which will spit out the branch name.
in_git_repo() {
#[[ `git branch 2>/dev/null` ]] && echo 'on '
if [[ -d './.git' ]]; then
echo -e "\e[37;1m on \e[34;1m$(git_branch)"
fi
}
# Get the active branch which has a * prefix.
git_branch() {
git branch | grep ^*
}
# Cooler prompt, orig below
# export PS1="\[\033[01;37m\][\[\033[01;32m\]\u@\h\[\033[01;37m\]:\[\033[01;34m\]\w\[\033[01;37m\]] # \[\033[00m\]"
#Black 0;30 Dark Gray 1;30
#Blue 0;34 Light Blue 1;34
#Green 0;32 Light Green 1;32
#Cyan 0;36 Light Cyan 1;36
#Red 0;31 Light Red 1;31
#Purple 0;35 Light Purple 1;35
#Brown 0;33 Yellow 1;33
#Light Gray 0;37 White 1;37
#export PS1='\[\e[1;31m\]\u \[\e[37;1m\]on \[\e[35;1m\]\h \[\e[37;1m\]in \[\e[36;1m\]\w \[\e[37;1m\]$(in_git_repo)\[\e[34;1m\]$(git_branch)\n\[\e[37;1m\] \$ \[\e[0m\]'
export PS1='\[\e[1;31m\]\u \[\e[37;1m\]on \[\e[35;1m\]\h \[\e[37;1m\]in \[\e[36;1m\]\w \[\e[37;1m\]$(in_git_repo)\n\[\e[37;1m\] \$ \[\e[0m\]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment