jeffreytse / zsh-vi-mode

💻 A better and friendly vi(vim) mode plugin for ZSH.
MIT License
3.29k stars 112 forks source link

Cursor style maintained across terminals #11

Open oars opened 3 years ago

oars commented 3 years ago

With TMux the cursor style is changed across all terminals.

Ideally I would love to be able to have a block style outside of the shell. So even if I was in insert mode with a pipe, when I go into vim for example I'd like it to go back to a block. Similarly if I go to a different terminal I'd like it to be independent, although I don't know how feasible that is.

jeffreytse commented 3 years ago

Hi @oars

Since Tmux is a terminal multiplexer, simply speaking, multiple windows and panes share a single terminal window. So when you switch between pannels, you will meet that the cursor style was not changed, in fact it is the same terminal as we known, unless it is updated by the program in another panel, but luckly the vim or nvim will update the cursor stlyle when you press some keys and auto update by its timer), this plugin will also update the cursor style when you press any key.

Thanks and regards

jeffreytse commented 3 years ago

Hi @oars

Thanks for your patience, this issue has been fixed on #35. Welcome to update your plugin to the latest version.

Thanks and regards

androidfans commented 3 years ago

Mar-17-2021 22-32-24

@jeffreytse can still repro this bug. it always makes me want press an i to enter insert mode when i am already in insert mode

jeffreytse commented 3 years ago

Hi @oars , in fact, this is not a bug, since you are using a terminal multiplexer, the zsh can not get the events of changing terminal, it is only one terminal for the virtual terminal emulators (such as iTerm, Xfce, etc.), now there is no a better solution for this issue. If you open a nvim and a zsh in the same time, you will observe that the zsh's cursor will change to block style after waiting for a while, since the nvim will update the cursor style by timer automatically.

androidfans commented 3 years ago

ok. may be tmux has some configuration to generate this event. let me find

androidfans commented 3 years ago

@jeffreytse set -g focus-events on may be helped. just want sleep .will try it tomorow

jeffreytse commented 3 years ago

@androidfans I knew this option and this is a configure of tmux, is it? The key to the problem is that I can get the event callback when the window is focused back.

jeffreytse commented 3 years ago

Hi @androidfans , in fact this issue already was added to my todo list, I will focus on this issue and try to settle it down, any updates I will update here, thanks you for the help.

androidfans commented 3 years ago

yes, it's tmux. have found another link may help https://github.com/tmux/tmux/issues/2059

HsunGong commented 3 years ago

Neither https://github.com/jeffreytse/zsh-vi-mode/issues/11#issuecomment-801145881 nor https://github.com/tmux/tmux/issues/2059 helps though.

zhyu commented 2 years ago

I'm having the same issue.

Before using zsh-vi-mode, I was using the vi-mode plugin of oh-my-zsh, which has a VI_MODE_RESET_PROMPT_ON_MODE_CHANGE option solves this issue. I wonder can we do something similar here?