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.
This commit is contained in:
Kenneth Benzie 2018-01-02 16:18:07 +00:00
parent a450b3cb45
commit 2c189c87e6

15
zshrc
View File

@ -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