]>
Commit | Line | Data |
---|---|---|
a40a5ec5 BB |
1 | function prompt_ben_precmd { |
2 | git-info | |
3 | } | |
4 | ||
5 | function rvm_info { | |
6 | echo '('`rvm-prompt v p g`')' | |
7 | } | |
8 | ||
9 | function virtualenv_info { | |
10 | if [[ -z "$VIRTUAL_ENV" ]]; then | |
11 | venv="default" | |
12 | else | |
13 | venv="${VIRTUAL_ENV##*/}" | |
14 | fi | |
15 | echo "(${venv})" | |
16 | } | |
17 | ||
18 | function box_name { | |
19 | [ -f ~/.box-name ] && cat ~/.box-name || hostname -s | |
20 | } | |
21 | ||
22 | function zle-line-init zle-keymap-select { | |
23 | local return_status="%{%F{red}%}%(?..✘)%{$reset_color%}" | |
24 | RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}${return_status}%{$reset_color%}" | |
25 | RPS2=$RPS1 | |
26 | zle reset-prompt | |
27 | } | |
28 | zle -N zle-line-init | |
29 | zle -N zle-keymap-select | |
30 | ||
31 | function prompt_ben_setup { | |
32 | setopt LOCAL_OPTIONS | |
33 | unsetopt XTRACE KSH_ARRAYS | |
34 | prompt_opts=(cr percent subst) | |
35 | ||
36 | # Load required functions. | |
37 | autoload -Uz add-zsh-hook | |
38 | ||
39 | # Add hook for calling git-info before each command. | |
40 | add-zsh-hook precmd prompt_ben_precmd | |
41 | ||
42 | # Set git-info parameters. | |
43 | zstyle ':prezto:module:git:info' verbose 'yes' | |
44 | zstyle ':prezto:module:git:info:branch' format '@%F{blue}%b%f' | |
45 | zstyle ':prezto:module:git:info:clean' format '' | |
46 | zstyle ':prezto:module:git:info:added' format '%{%F{green}%}!' | |
47 | zstyle ':prezto:module:git:info:modified' format '%{%F{green}%}?' | |
48 | zstyle ':prezto:module:git:info:untracked' format '%{%F{red}%}?' | |
49 | zstyle ':prezto:module:git:info:keys' format \ | |
50 | 'prompt' '%b%a%m%u' | |
51 | ||
52 | # Define prompts. | |
53 | PROMPT=' | |
54 | %{%F{red}%}%n%{%f%}@%{%F{yellow}%}$(box_name)%{%f%} %{%B%F{green}%}${PWD/#$HOME/~}%{%f%b%}${git_info[prompt]} %{%F{black}%}$(rvm_info)$(virtualenv_info)%{%f%} | |
55 | %(?,,%{${%B%F{white}%}[%?]%{%f%b%} )$ ' | |
56 | } | |
57 | ||
58 | prompt_ben_setup "$@" | |
59 | ||
60 | #setopt PROMPT_SUBST | |
61 | ||
62 | ZSH_THEME_GIT_PROMPT_PREFIX="@%{%F{blue}%}" | |
63 | ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" | |
64 | ZSH_THEME_GIT_PROMPT_DIRTY="%{%F{green}%}!" | |
65 | ZSH_THEME_GIT_PROMPT_UNTRACKED="%{%F{green}%}?" | |
66 | ZSH_THEME_GIT_PROMPT_CLEAN="" | |
67 |