From 2c189c87e6b81685bf6fa87e351d6ff118974265 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 2 Jan 2018 16:18:07 +0000 Subject: [PATCH] Support changing cursor shape in iTerm2 in tmux Depends on setting the following in `.tmux.conf`: set -ga terminal-overrides '*:Ss=\E]1337;CursorShape=%p1%d\7' This allows changing the iTerm2 cursor shape using the same escape sequences as used for VTE compatible terminals. --- zshrc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/zshrc b/zshrc index 9fe4c58..c4d3e16 100644 --- a/zshrc +++ b/zshrc @@ -81,16 +81,13 @@ bindkey -M vicmd '^V' edit-command-line ppid_name() { echo $(ps -p $(ps -p $(echo $$) -o ppid=) -o comm=) } # Enable changing cursor shape based on vi mode -if [ "$ITERM_PROFILE" != "" ]; then - # TODO: This only works outside tmux, unlike VTE compatible terminals I've - # not found a tmux terminal-override which works with iTerm2's CursorShape - # escape sequences. - # iTerm2 cursor shape escape sequences - cursor_block="\E]50;CursorShape=0\C-G" - cursor_line="\E]50;CursorShape=1\C-G" +if [ "$ITERM_PROFILE" != "" ] && [ "$TMUX" = "" ]; then + # iTerm2 cursor shape escape sequences outside tmux + cursor_block="\e]50;CursorShape=0\C-G" + cursor_line="\e]50;CursorShape=1\C-G" elif [ "$(ppid_name)" != "python2" ]; then - # VTE compatible cursor shape escape sequences, excluding Guake even though - # it is VTE based it doesn't seem to handle these properly + # iTerm2 inside tmux or VTE compatible cursor shape escape sequences, + # exclude Guake even though it's VTE based it doesn't like these cursor_block="\e[2 q" cursor_line="\e[6 q" fi