Show current mode in Vi mode (2022-08-19 07:46 by awkless #91061)
Is there any way to show the current mode of operation when 'set -o vi' is enabled? I looked through the manual, especially the line-editing section, and I cannot find anything about displaying the current Vi mode that the shell is in. Is this not a feature of Yash? Or did I skip a section in the manual?
Re: Show current mode in Vi mode (2022-09-08 17:39 by WolfsDream #91414)
Reply To Message #91124
> Reply To Message #91078
> > Unfortunately, there is no way to tell whether the current state is the insert mode or the normal mode in a visual manner.
>
> Thank you for letting me know.
In zsh it can be done like this:
is it possible to have something similar?
changing to beam shape cursor works in yash too
# Change cursor shape for different vi modes.
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne '\e[5 q'
fi
}
zle -N zle-keymap-select
zle-line-init() {
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
echo -ne "\e[5 q"
}
zle -N zle-line-init
echo -ne '\e[5 q' # Use beam shape cursor on startup.
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.