p="${${SSH_CLIENT+$s}:-$p}"
local clock="%F{$n}%T%f" dirvcs="%F{$d}"'${vcs_info_msg_0_:-%~}'"%f"
+ # XXX: linux only
local battery=/sys/class/power_supply/BAT0/capacity
[[ -e "$battery" ]] && clock+=" `cat $battery`%%"
local vicol='%F{${${prompt_arrows_vimode:+'"$r"'}:-'"$c"'}}'
+ local hist="%F{$n}%h"
case "$m" {
2line)
- PROMPT="%f $clock $dirvcs"$'\n'"%F{$c}>>> "
+ PROMPT="%f $hist $clock $dirvcs"$'\n'"%F{$c}>>> "
unset RPROMPT
;;
right)
RPROMPT="$dirvcs $clock"
- PROMPT="%F{$c}>>> "
+ PROMPT="%F{$c}>>> $hist"
;;
*)
echo "Unknown prompt mode $m"
zstyle ':vcs_info:git*' stagedstr "%F{$c}+"
zstyle ':vcs_info:git*' unstagedstr "%F{$r}*"
+ # add-zsh-hook should have already been autoloaded by promptinit
add-zsh-hook precmd prompt_arrows_precmd
add-zsh-hook preexec prompt_arrows_preexec
- zle -N zle-line-init
- zle -A zle-line-init zle-keymap-select
+ autoload -Uz add-zle-hook-widget
+ add-zle-hook-widget line-init prompt_arrows_keymap_select
+ add-zle-hook-widget keymap-select prompt_arrows_keymap_select
}
# change color based on zle vi mode
-function zle-line-init {
+function prompt_arrows_keymap_select {
prompt_arrows_vimode="${KEYMAP:/(main|viins)/}"
zle reset-prompt
}