From fb1b6a3bdaa4bd3c593759da60735c1ef483b0b3 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Fri, 18 Nov 2022 20:34:32 +0100 Subject: [PATCH] zsh: fix changing cursor shape in tmux + iTerm2 Most terminals use the VT520 DECSCUSR escape sequences for setting the cursor shape, documented at: https://invisible-island.net/xterm/ctlseqs/ctlseqs.txt iTerm2, however, uses a set of proprietary escape codes, documented at: https://iterm2.com/documentation-escape-codes.html The issue I had was that tmux recognizes the VT520 DECSCUSR codes and knows how to translate them itself to iTerm2. But tmux does not accept the iTerm2 codes as input, so deciding to use these proprietary codes only based on the presence of `$ITERM_SESSION_ID` did not work when running tmux. The solution is to revert to the VT520 codes when running inside of tmux (even inside iTerm2) and let it translate to iTerm2. --- config/zsh/vi-mode.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/zsh/vi-mode.zsh b/config/zsh/vi-mode.zsh index 3eba13e..243802f 100644 --- a/config/zsh/vi-mode.zsh +++ b/config/zsh/vi-mode.zsh @@ -6,7 +6,7 @@ set_cursor_shape() { local block='\e[1 q' # blinking block local underline='\e[3 q' # blinking underline, 4 for steady local bar='\e[5 q' # blinkind bar, 6 for steady - if [[ -n $ITERM_SESSION_ID ]] { + if [[ -n "$ITERM_SESSION_ID" && -z "$TMUX" ]] { block='\e]1337;CursorShape=0\a' bar='\e]1337;CursorShape=1\a' underline='\e]1337;CursorShape=2\a'