diff --git a/zshrc b/zshrc index 1ed03b0..9fe4c58 100644 --- a/zshrc +++ b/zshrc @@ -77,21 +77,23 @@ autoload -U edit-command-line zle -N edit-command-line bindkey -M vicmd '^V' edit-command-line +# Get the shells parent process name. +ppid_name() { echo $(ps -p $(ps -p $(echo $$) -o ppid=) -o comm=) } + # Enable changing cursor shape based on vi mode -if [ "$TMUX" != "" ]; then - tmux_before="\EPtmux;\E" - tmux_after="\E\\" +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" +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 + cursor_block="\e[2 q" + cursor_line="\e[6 q" fi -if [ "$ITERM_SESSION_ID" != "" ]; then - # iterm2 cursor shape escape sequences - cursor_block="$tmux_before\E]50;CursorShape=0\C-G$tmux_after" - cursor_line="$tmux_before\E]50;CursorShape=1\C-G$tmux_after" -else - # VTE compatible cursor shape escape sequences - cursor_block="$tmux_before\E[2 q$tmux_after" - cursor_line="$tmux_before\E[6 q$tmux_after" -fi -unset tmux_before tmux_after if [[ ! -z "$cursor_block" && ! -z "$cursor_line" ]]; then # Change cursor shape when vi mode changes