Skip to content

Instantly share code, notes, and snippets.

@tonyjcamp
Created February 27, 2012 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tonyjcamp/1921784 to your computer and use it in GitHub Desktop.
Save tonyjcamp/1921784 to your computer and use it in GitHub Desktop.
zsh Theme
# https://github.com/blinks zsh theme
function _prompt_char() {
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
echo "%{%F{blue}%}±%{%f%k%b%}"
else
echo ' '
fi
}
#ZSH_THEME_GIT_PROMPT_PREFIX=" [%{%B%F{blue}%}"
#ZSH_THEME_GIT_PROMPT_SUFFIX="%{%f%k%b%K{black}%B%F{green}%}]"
#ZSH_THEME_GIT_PROMPT_DIRTY=" %{%F{red}%}*%{%f%k%b%}"
#ZSH_THEME_GIT_PROMPT_CLEAN=""
project_pwd() {
echo $PWD | sed -e "s/\/Users\/$USER/~/" -e "s/~\/projects\/\([^\/]*\)\/current/\\1/" -e "s/~\/Sites\/\([^\/]*\)\/current/http:\/\/\\1/"
}
ruby_version() {
echo " $(ruby -v | awk '{print $2}')"
}
in_git_repo() {
[ $PWD != "/Users/$HOME" ] && [ -d '.git' ]
}
git_parse_branch() {
sed -e 's/^.*refs\/heads\///' '.git/HEAD'
}
git_head_commit_id() {
cut -c 1-7 ".git/refs/heads/`git_parse_branch`"
}
git_cwd_dirty() {
[[ `git ls-files -m` == '' ]] || echo ' +'
}
git_cwd_info() {
if in_git_repo; then
echo -n " %{\e[1;35m%}`git_parse_branch`%{\e[0;35m%}@%{\e[1;35m%}`git_head_commit_id``git_cwd_dirty`%{\e[1;35m%}"
fi
}
export PROMPT=$'%{\e[1;34m%}%n@\e[1;34m%M%{\e[0m%}
%{\e[0;%(?.32.31)m%}>%{\e[0m%} '
export RPROMPT=$'%{\e[1;31m%}$(project_pwd)%{\e[0;34m%}$(ruby_version)$(git_cwd_info)%{\e[0m%}'
#Original blinks prompt
#PROMPT='
#%{%K{black}%}$(_prompt_char)%{%K{black}%} %#%{%f%k%b%} '
#RPROMPT='%{%b%F{yellow}%K{black}%}%~%{%B%F{green}%}$(git_prompt_info)'
@rxgx
Copy link

rxgx commented Feb 27, 2012

y u no liek bash?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment