]> Sergey Matveev's repositories - dotfiles.git/blob - zsh/.zsh/rc/015prompt.zsh
Change cursor's colour based on vi-mode
[dotfiles.git] / zsh / .zsh / rc / 015prompt.zsh
1 setopt PROMPT_SUBST
2
3 PS1="%2~ %B"
4 PS1+='${(j::)psvar}'
5 PS1+="%(1j.%j.)%b"
6 PS1+='%U${vcs_info_msg_0_}%u'
7 PS1+="%(?.. %S%?%s)"
8 PS1+='%(1S. %B${SECONDS}%b.)'
9 PS1+='%B%F{magenta}%#%f%b '
10
11 function zle-line-init zle-keymap-select {
12     printf "\e]12;"
13     [[ ${KEYMAP} == vicmd ]] && printf "red" || printf "green"
14     printf "\e\\"
15     [[ "$#_autoenv_stack_entered" -eq 0 ]] && psvar=(${psvar#A}) || {
16         [[ -n "${psvar[(r)A]}" ]] || psvar=(A $psvar)
17     }
18     [[ -z "$VIRTUAL_ENV" ]] && psvar=(${psvar#V}) || {
19         [[ -n "${psvar[(r)V]}" ]] || psvar=(V $psvar)
20     }
21     zle reset-prompt
22 }
23
24 zle -N zle-line-init
25 zle -N zle-keymap-select
26
27 preexec() {
28     SECONDS=0
29 }
30
31 precmd() {
32     printf "\a\e]2;\e\\"
33     vcs_info
34 }