]> git.r.bdr.sh - rbdr/dotfiles/blame_incremental - prompt_ben_setup
Update prompt to show ruby & node envs
[rbdr/dotfiles] / prompt_ben_setup
... / ...
CommitLineData
1function prompt_ben_precmd {
2 git-info
3}
4
5function virtualenv_info {
6 if [[ -z "$VIRTUAL_ENV" ]]; then
7 venv="default"
8 else
9 venv="${VIRTUAL_ENV##*/}"
10 fi
11 echo "🐍${venv}"
12}
13
14function rvm_info {
15 if [[ -z "$RUBY_VERSION" ]]; then
16 rvminfo="default"
17 else
18 rvminfo=`rvm-prompt`
19 fi
20 echo "💎${rvminfo}"
21}
22
23function nvm_info {
24 if [[ -z "$NVM_BIN" ]]; then
25 nvminfo="default"
26 else
27 nvminfo=`nvm current`
28 fi
29 echo "💛${nvminfo}"
30}
31
32function box_name {
33 [ -f ~/.box-name ] && cat ~/.box-name || hostname -s
34}
35
36function 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}
42zle -N zle-line-init
43zle -N zle-keymap-select
44
45function 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{blue}%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{red}%}?'
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{red}%}%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
73prompt_ben_setup "$@"
74
75#setopt PROMPT_SUBST
76
77ZSH_THEME_GIT_PROMPT_PREFIX="@%{%F{blue}%}"
78ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
79ZSH_THEME_GIT_PROMPT_DIRTY="%{%F{green}%}!"
80ZSH_THEME_GIT_PROMPT_UNTRACKED="%{%F{green}%}?"
81ZSH_THEME_GIT_PROMPT_CLEAN=""
82