Skip to content

Instantly share code, notes, and snippets.

@richo
Created March 15, 2012 03:28
Show Gist options
  • Save richo/2041695 to your computer and use it in GitHub Desktop.
Save richo/2041695 to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
function __richo_pwd()
{
local current=$PWD
richo_prompt=no
if [ -e ".svn" ]; then
export richo_prompt="⚡"
fi
while [ "$current" != '/' -a $richo_prompt = "no" ]; do
# for n in n; do
if [ -e "$current/.git" ]; then
export richo_prompt="±"
break
fi
if [ -e "$current/.hg" ]; then
export richo_prompt="☿"
break
fi
if [ -e "$current/.bzr" ]; then
export richo_prompt="⤴"
break
fi
current=$current:h
done
if [ $richo_prompt != "no" ]; then
if [ "$current" = "$HOME" ]; then
repo="~"
suff=${PWD##$current}
export richo_pwd="$PR_BRIGHT_WHITE${repo}$PR_BRIGHT_BLUE$suff"
else
pref=$current:h
suff=${PWD##$current}
repo=$current:t
richo_pwd="$pref/$PR_DULL_WHITE${repo}$PR_BRIGHT_BLUE$suff"
export richo_pwd=${richo_pwd/$HOME/\~}
fi
else
export richo_prompt='%#'
export richo_pwd="${PWD/$HOME/~}"
fi
}
__richo_pwd
add-zsh-hook chpwd __richo_pwd
PS1="${SHELL_COLOR}%(?.%m.\$(__richo_host) $PR_BRIGHT_RED%?)%b $PR_BRIGHT_BLUE\$richo_prompt $PR_RESET"
RPS1="$PR_BRIGHT_BLUE\$richo_pwd "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment