Post History
Question What is the simplest way to change the cursor to indicate vim mode when using zsh? Notes I want it to show as a vertical line in insert mode and a block in normal mode. This is the cur...
#3: Post edited
- What is the simplest way to change the cursor to indicate vim mode when using zsh?
- I want it to show as a vertical line in insert mode and a block in normal mode.
- This is the current code I am using:
- ```sh
- # change cursor shape for different vi modes
- cursor_mode() {
- # See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes
- cursor_block='\e[2 q'
- cursor_beam='\e[6 q'
- function zle-keymap-select {
- if [[ ${KEYMAP} == vicmd ]] ||
- [[ $1 = 'block' ]]; then
- echo -ne $cursor_block
- elif [[ ${KEYMAP} == main ]] ||
- [[ ${KEYMAP} == viins ]] ||
- [[ ${KEYMAP} = '' ]] ||
- [[ $1 = 'beam' ]]; then
- echo -ne $cursor_beam
- fi
- }
- zle-line-init() {
- echo -ne $cursor_beam
- }
- zle -N zle-keymap-select
- zle -N zle-line-init
- }
- cursor_mode
- ```
- # Question
- What is the simplest way to change the cursor to indicate vim mode when using zsh?
- # Notes
- I want it to show as a vertical line in insert mode and a block in normal mode.
- This is the current code I am using:
- ```sh
- # change cursor shape for different vi modes
- cursor_mode() {
- # See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes
- cursor_block='\e[2 q'
- cursor_beam='\e[6 q'
- function zle-keymap-select {
- if [[ ${KEYMAP} == vicmd ]] ||
- [[ $1 = 'block' ]]; then
- echo -ne $cursor_block
- elif [[ ${KEYMAP} == main ]] ||
- [[ ${KEYMAP} == viins ]] ||
- [[ ${KEYMAP} = '' ]] ||
- [[ $1 = 'beam' ]]; then
- echo -ne $cursor_beam
- fi
- }
- zle-line-init() {
- echo -ne $cursor_beam
- }
- zle -N zle-keymap-select
- zle -N zle-line-init
- }
- cursor_mode
- ```
#2: Post edited
- What is the simplest way to change the cursor to indicate vim mode when using zsh?
- This is the current code I am using:
- ```sh
- # change cursor shape for different vi modes
- cursor_mode() {
- # See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes
- cursor_block='\e[2 q'
- cursor_beam='\e[6 q'
- function zle-keymap-select {
- if [[ ${KEYMAP} == vicmd ]] ||
- [[ $1 = 'block' ]]; then
- echo -ne $cursor_block
- elif [[ ${KEYMAP} == main ]] ||
- [[ ${KEYMAP} == viins ]] ||
- [[ ${KEYMAP} = '' ]] ||
- [[ $1 = 'beam' ]]; then
- echo -ne $cursor_beam
- fi
- }
- zle-line-init() {
- echo -ne $cursor_beam
- }
- zle -N zle-keymap-select
- zle -N zle-line-init
- }
- cursor_mode
- ```
- What is the simplest way to change the cursor to indicate vim mode when using zsh?
- I want it to show as a vertical line in insert mode and a block in normal mode.
- This is the current code I am using:
- ```sh
- # change cursor shape for different vi modes
- cursor_mode() {
- # See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes
- cursor_block='\e[2 q'
- cursor_beam='\e[6 q'
- function zle-keymap-select {
- if [[ ${KEYMAP} == vicmd ]] ||
- [[ $1 = 'block' ]]; then
- echo -ne $cursor_block
- elif [[ ${KEYMAP} == main ]] ||
- [[ ${KEYMAP} == viins ]] ||
- [[ ${KEYMAP} = '' ]] ||
- [[ $1 = 'beam' ]]; then
- echo -ne $cursor_beam
- fi
- }
- zle-line-init() {
- echo -ne $cursor_beam
- }
- zle -N zle-keymap-select
- zle -N zle-line-init
- }
- cursor_mode
- ```
#1: Initial revision
Simplest way to change cursor to indicate vim mode
What is the simplest way to change the cursor to indicate vim mode when using zsh? This is the current code I am using: ```sh # change cursor shape for different vi modes cursor_mode() { # See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes cursor_block='\e[2 q' cursor_beam='\e[6 q' function zle-keymap-select { if [[ ${KEYMAP} == vicmd ]] || [[ $1 = 'block' ]]; then echo -ne $cursor_block elif [[ ${KEYMAP} == main ]] || [[ ${KEYMAP} == viins ]] || [[ ${KEYMAP} = '' ]] || [[ $1 = 'beam' ]]; then echo -ne $cursor_beam fi } zle-line-init() { echo -ne $cursor_beam } zle -N zle-keymap-select zle -N zle-line-init } cursor_mode ```