Skip to content

Instantly share code, notes, and snippets.

@eddywashere
Last active December 10, 2015 04:48
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 eddywashere/4383997 to your computer and use it in GitHub Desktop.
Save eddywashere/4383997 to your computer and use it in GitHub Desktop.
An awesome oh-my-zsh theme
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '±' && return
hg root >/dev/null 2>/dev/null && echo '' && return
svn info >/dev/null 2>/dev/null && echo 'ಠ_ಠ' && return
echo ''
}
function virtualenv_info {
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
}
function hg_prompt_info {
hg prompt --angle-brackets "\
< on %{$fg[magenta]%}<branch>%{$reset_color%}>\
< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
%{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
}
function svn_prompt_info {
# Set up defaults
local svn_branch=""
local svn_repository=""
local svn_version=""
local svn_change=""
# only if we are in a directory that contains a .svn entry
if [ -d ".svn" ]; then
# query svn info and parse the results
svn_branch=`svn info | grep '^URL:' | egrep -o '((tags|branches)/[^/]+|trunk).*' | sed -E -e 's/^(branches|tags)\///g'`
svn_repository=`svn info | grep '^Repository Root:' | egrep -o '(http|https|file|svn|svn+ssh)/[^/]+' | egrep -o '[^/]+$'`
svn_version=`svnversion -n`
# this is the slowest test of the bunch
change_count=`svn status | grep "?\|\!\|M\|A" | wc -l`
if [ "$change_count" != " 0" ]; then
svn_change=" [dirty]"
else
svn_change=""
fi
# show the results
echo " [%{$fg[blue]%}$svn_repository/$svn_branch @ $svn_version%{$reset_color%}%{$fg[yellow]%}$svn_change%{$reset_color%}]"
fi
}
# ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
# ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
# ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
# ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
# ZSH_THEME_GIT_PROMPT_CLEAN=""
local return_status="%{$fg[red]%}%(?..✘)%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$fg[cyan]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}] %{$fg_bold[yellow]%}⚡%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}]"
function precmd() {
print -rP '%{$fg_bold[magenta]%}%n%{$reset_color%}$fg[magenta][%{$fg[yellow]%}%m%{$reset_color%}$fg[magenta]] %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(hg_prompt_info)$(git_prompt_info)$(svn_prompt_info) $(virtualenv_info)'
}
PROMPT='$(prompt_char) '
# ----------------------------------------------------------------------------
# svn prompt
# based on: https://gist.github.com/1156969
# with help from: http://andrewray.me/bash-prompt-builder/index.html
# ----------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment