Skip to content

VI Mode Cursor Not Working in iTerm and Tmux #9172

@dkolb

Description

@dkolb

Fish version: 3.5.1
tmux version: 3.3a
iTerm version: 3.4.16

Minimal fish config:

set fish_cursor_default block
set fish_cursor_insert line
set fish_cursor_replace_one underscore
set fish_cursor_visual block

fish_vi_key_bindings

When running tmux with this configuration the cursors do not change. However, if I run fish_vi_cursor xterm in my shell, the cursor will begin to work. (Synthesized this from reviewing #8981 and the relevant functions.)

The weird part is if I do this in my fish config:

set fish_cursor_default block
set fish_cursor_insert line
set fish_cursor_replace_one underscore
set fish_cursor_visual block

fish_vi_key_bindings

if set -q TMUX
  fish_vi_cursor xterm
end

It still does not work. It only works if I either manipulate the environment before calling fish_vi_key_bindings (specifically, clearing the ITERM_PROFILE environment variable) or if I call fish_vi_cursor xterm on the command line.

Using sh -c 'env HOME=$(mktemp -d) fish' and then launching tmux (giving the default configuration for tmux) does not change this behavior:

[I] > fish_vi_key_bindings
[I] > set -x fish_cursor_insert line
[I] > set -x fish_cursor_default block
[I] > echo cursor is block
cursor is block
[I] > fish_vi_cursor xterm
[I] > echo cursor is line
cursor is line
[I] >

Various workarounds that fix this behavior:

Adding this to my config.fish so fish_vi_cursor doesn't know it's inside iTerm:

if set -q TMUX
  set -e ITERM_PROFILE
end

But a simpler and more generic solution is possible. As #8981 implied, it appears DECSCUSR support was added back in 2012 to iTerm? (See: gnachman/iTerm2#92 ) I'm not terribly good at terminal emulator specifics, admittedly. So deleting these lines in fish_vi_cursor.fish so that we end up using the __fish_cursor_xterm function instead of the __fish_cursor_1337 function seems to make everything work across both tmux and iTerm.

I've been running this last workaround for a few weeks and it seems to work fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions