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