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=) } ppid_name() { echo $(ps -p $(ps -p $(echo $$) -o ppid=) -o comm=) }
# Enable changing cursor shape based on vi mode # Enable changing cursor shape based on vi mode
if [ "$ITERM_PROFILE" != "" ]; then if [ "$ITERM_PROFILE" != "" ] && [ "$TMUX" = "" ]; then
# TODO: This only works outside tmux, unlike VTE compatible terminals I've # iTerm2 cursor shape escape sequences outside tmux
# not found a tmux terminal-override which works with iTerm2's CursorShape cursor_block="\e]50;CursorShape=0\C-G"
# escape sequences. cursor_line="\e]50;CursorShape=1\C-G"
# iTerm2 cursor shape escape sequences
cursor_block="\E]50;CursorShape=0\C-G"
cursor_line="\E]50;CursorShape=1\C-G"
elif [ "$(ppid_name)" != "python2" ]; then elif [ "$(ppid_name)" != "python2" ]; then
# VTE compatible cursor shape escape sequences, excluding Guake even though # iTerm2 inside tmux or VTE compatible cursor shape escape sequences,
# it is VTE based it doesn't seem to handle these properly # exclude Guake even though it's VTE based it doesn't like these
cursor_block="\e[2 q" cursor_block="\e[2 q"
cursor_line="\e[6 q" cursor_line="\e[6 q"
fi fi