peepcode.zsh-theme
1178 bytes
1#
2# Based on Geoffrey Grosenbach's peepcode zsh theme from
3# https://github.com/topfunky/zsh-simple
4#
5
6git_repo_path() {
7 command git rev-parse --git-dir 2>/dev/null
8}
9
10git_commit_id() {
11 command git rev-parse --short HEAD 2>/dev/null
12}
13
14git_mode() {
15 if [[ -e "$repo_path/BISECT_LOG" ]]; then
16 echo "+bisect"
17 elif [[ -e "$repo_path/MERGE_HEAD" ]]; then
18 echo "+merge"
19 elif [[ -e "$repo_path/rebase" || -e "$repo_path/rebase-apply" || -e "$repo_path/rebase-merge" || -e "$repo_path/../.dotest" ]]; then
20 echo "+rebase"
21 fi
22}
23
24git_dirty() {
25 if [[ "$repo_path" != '.' && -n "$(command git ls-files -m)" ]]; then
26 echo " %{$fg_bold[grey]%}✗%{$reset_color%}"
27 fi
28}
29
30git_prompt() {
31 local cb=$(git_current_branch)
32 if [[ -n "$cb" ]]; then
33 local repo_path=$(git_repo_path)
34 echo " %{$fg_bold[grey]%}${cb//\%/%%} %{$fg[white]%}$(git_commit_id)%{$reset_color%}$(git_mode)$(git_dirty)"
35 fi
36}
37
38local smiley='%(?.%F{green}☺%f.%F{red}☹%f)'
39
40PROMPT='
41${VIRTUAL_ENV:+"($VIRTUAL_ENV) "}%~
42${smiley} '
43
44RPROMPT='%F{white} $(ruby_prompt_info)$(git_prompt)%{$reset_color%}'
45
46# Disable automatic virtualenv prompt change
47export VIRTUAL_ENV_DISABLE_PROMPT=1