Parent directory

half-life.zsh-theme

2952 bytes
 1# prompt style and colors based on Steve Losh's Prose theme:
 2# https://github.com/sjl/oh-my-zsh/blob/master/themes/prose.zsh-theme
 3#
 4# vcs_info modifications from Bart Trojanowski's zsh prompt:
 5# http://www.jukie.net/bart/blog/pimping-out-zsh-prompt
 6#
 7# git untracked files modification from Brian Carper:
 8# https://briancarper.net/blog/570/git-info-in-your-zsh-prompt
 9
10#use extended color palette if available
11if [[ $TERM = (*256color|*rxvt*) ]]; then
12  turquoise="%{${(%):-"%F{81}"}%}"
13  orange="%{${(%):-"%F{166}"}%}"
14  purple="%{${(%):-"%F{135}"}%}"
15  hotpink="%{${(%):-"%F{161}"}%}"
16  limegreen="%{${(%):-"%F{118}"}%}"
17else
18  turquoise="%{${(%):-"%F{cyan}"}%}"
19  orange="%{${(%):-"%F{yellow}"}%}"
20  purple="%{${(%):-"%F{magenta}"}%}"
21  hotpink="%{${(%):-"%F{red}"}%}"
22  limegreen="%{${(%):-"%F{green}"}%}"
23fi
24
25autoload -Uz vcs_info
26# enable VCS systems you use
27zstyle ':vcs_info:*' enable git svn
28
29# check-for-changes can be really slow.
30# you should disable it, if you work with large repositories
31zstyle ':vcs_info:*:prompt:*' check-for-changes true
32
33# set formats
34# %b - branchname
35# %u - unstagedstr (see below)
36# %c - stagedstr (see below)
37# %a - action (e.g. rebase-i)
38# %R - repository path
39# %S - path in the repository
40PR_RST="%{${reset_color}%}"
41FMT_BRANCH=" on ${turquoise}%b%u%c${PR_RST}"
42FMT_ACTION=" performing a ${limegreen}%a${PR_RST}"
43FMT_UNSTAGED="${orange} ●"
44FMT_STAGED="${limegreen} ●"
45
46zstyle ':vcs_info:*:prompt:*' unstagedstr   "${FMT_UNSTAGED}"
47zstyle ':vcs_info:*:prompt:*' stagedstr     "${FMT_STAGED}"
48zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH}${FMT_ACTION}"
49zstyle ':vcs_info:*:prompt:*' formats       "${FMT_BRANCH}"
50zstyle ':vcs_info:*:prompt:*' nvcsformats   ""
51
52
53function steeef_chpwd {
54  PR_GIT_UPDATE=1
55}
56
57function steeef_preexec {
58  case "$2" in
59  *git*|*svn*) PR_GIT_UPDATE=1 ;;
60  esac
61}
62
63function steeef_precmd {
64  (( PR_GIT_UPDATE )) || return
65
66  # check for untracked files or updated submodules, since vcs_info doesn't
67  if [[ -n "$(git ls-files --other --exclude-standard 2>/dev/null)" ]]; then
68    PR_GIT_UPDATE=1
69    FMT_BRANCH="${PM_RST} on ${turquoise}%b%u%c${hotpink} ●${PR_RST}"
70  else
71    FMT_BRANCH="${PM_RST} on ${turquoise}%b%u%c${PR_RST}"
72  fi
73  zstyle ':vcs_info:*:prompt:*' formats       "${FMT_BRANCH}"
74
75  vcs_info 'prompt'
76  PR_GIT_UPDATE=
77}
78
79# vcs_info running hooks
80PR_GIT_UPDATE=1
81
82autoload -U add-zsh-hook
83add-zsh-hook chpwd steeef_chpwd
84add-zsh-hook precmd steeef_precmd
85add-zsh-hook preexec steeef_preexec
86
87# ruby prompt settings
88ZSH_THEME_RUBY_PROMPT_PREFIX="with%F{red} "
89ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
90ZSH_THEME_RVM_PROMPT_OPTIONS="v g"
91
92# virtualenv prompt settings
93ZSH_THEME_VIRTUALENV_PREFIX=" with%F{red} "
94ZSH_THEME_VIRTUALENV_SUFFIX="%{$reset_color%}"
95
96setopt prompt_subst
97PROMPT="${purple}%n%{$reset_color%} in ${limegreen}%~%{$reset_color%}\$(virtualenv_prompt_info)\$(ruby_prompt_info)\$vcs_info_msg_0_${orange} λ%{$reset_color%} "