Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VI Mode Cursor Not Working in iTerm and Tmux #9172

Closed
dkolb opened this issue Aug 31, 2022 · 0 comments
Closed

VI Mode Cursor Not Working in iTerm and Tmux #9172

dkolb opened this issue Aug 31, 2022 · 0 comments
Labels
enhancement macos macOS-specific issue
Milestone

Comments

@dkolb
Copy link

dkolb commented Aug 31, 2022

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.

@dkolb dkolb changed the title VI Mode Cursor Not Working in Tmux VI Mode Cursor Not Working in iTerm and Tmux Aug 31, 2022
@faho faho added the macos macOS-specific issue label Sep 9, 2022
@faho faho closed this as completed in 011af34 Sep 26, 2022
@faho faho added this to the fish 3.6.0 milestone Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement macos macOS-specific issue
Projects
None yet
Development

No branches or pull requests

2 participants