Skip to content

Commit

Permalink
Allow tmux to handle cursor styling
Browse files Browse the repository at this point in the history
Since version 1.5, tmux has been able to handle cursor style sequences.

Fixes #23
  • Loading branch information
softmoth committed May 13, 2020
1 parent dd53834 commit 2e02a44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
18 changes: 11 additions & 7 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,19 @@ MODE_CURSOR_VISUAL="$MODE_CURSOR_VICMD steady bar"
MODE_CURSOR_VLINE="$MODE_CURSOR_VISUAL #00ffff"
```

Use X11 color names or `#RRGGBB` notation for colors. The recognized
style words are `steady`, `blinking`, `block`, `underline` and `bar`.
Use `#RRGGBB` notation for for colors. Your terminal application may
recognize X11 color names, `rgb:xxx/yyy/zzz` or other formats.

If your cursor used to blink, and now it's stopped, you can fix that
with `unset MODE_CURSOR_DEFAULT`. The default (steady) is
appropriate for most terminals.
The recognized style words are `steady`, `blinking`, `block`, `underline`
and `bar`.

If you are using `tmux` but `$TMUX` is not set (e.g., you're running
zsh on a remote host), you may need to set `TMUX_PASSTHROUGH=1` to
If your cursor used to blink, and now it's stopped, you can fix that with
`unset MODE_CURSOR_DEFAULT`. The default (steady) is appropriate for most
terminals.

If you are using `tmux` and cursor styles are not shown, first ensure that
your terminal application [reports its capabilities][SsSe] properly. If it
is an old version of tmux, you may need to set `TMUX_PASSTHROUGH=1` to
get the cursor styling to work.

When in VISUAL or VLINE mode, ZSH colors text in reverse (background and
Expand Down
15 changes: 6 additions & 9 deletions zsh-vim-mode.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ if [[ $VIM_MODE_TRACK_KEYMAP != no ]]; then

#${(%):-%x}_debug " -> $keymap"

[[ $VIM_MODE_KEYMAP = $keymap ]] && return
# FIXME: Temporary test for issue #23
#[[ $VIM_MODE_KEYMAP = $keymap ]] && return

# Can be used by prompt themes, etc.
VIM_MODE_KEYMAP=$keymap
Expand Down Expand Up @@ -540,16 +541,12 @@ if [[ $VIM_MODE_TRACK_KEYMAP != no ]]; then
local sequence="$1"
local is_tmux

# Allow forcing TMUX_PASSTHROUGH on. For example, if running tmux locally
# and running zsh remotely, where $TMUX is not set (and shouldn't be).
if [[ -n $TMUX_PASSTHROUGH ]] || [[ -n $TMUX ]]; then
is_tmux=1
fi

if [[ -n $is_tmux ]]; then
# Older TMUX (before 1.5) does not handle cursor styling and needs
# to be told to pass those escape sequences directly to the terminal
if [[ $TMUX_PASSTHROUGH = 1 ]]; then
# Double each escape (see zshbuiltins(1) echo for backslash escapes)
# And wrap it in the TMUX DCS passthrough
sequence=${sequence//\\(e|x27|033|u001[bB]|U0000001[bB])/\\e\\e}
sequence=${sequence//\\(e|x27|033|[uU]00*1[bB])/\\e\\e}
sequence="\ePtmux;$sequence\e\\"
fi
print -n "$sequence"
Expand Down

0 comments on commit 2e02a44

Please sign in to comment.