diff --git a/.tmux.conf b/.tmux.conf index 260397d..e724be0 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -71,3 +71,5 @@ bind-key -r J resize-pane -D 2 bind-key -r K resize-pane -U 2 bind-key -r H resize-pane -L 10 bind-key -r L resize-pane -R 10 + +set-option -g terminal-overrides '*88col*:colors=88,*256col*:colors=256,xterm*:XT:Ms=\E]52;%p1%s;%p2%s\007:Cs=\E]12;%p1%s\007:Cr=\E]112\007:Ss=\E]50;CursorShape=%?%p1%{3}%<%t%{0}%e%p1%{2}%-%;%d\007' diff --git a/.vimrc b/.vimrc index a82f3cf..7bba089 100644 --- a/.vimrc +++ b/.vimrc @@ -261,3 +261,9 @@ let g:ctrlp_prompt_mappings = { " Auto-open a split pane with an applicable diff for git commits autocmd FileType gitcommit DiffGitCached | wincmd L | wincmd p | vertical resize 83 + +" Change cursor shape between insert and normal mode in iTerm2.app +if $TERM_PROGRAM =~ "iTerm" + let &t_SI = "\Ptmux;\\]50;CursorShape=1\x7\\\" " Vertical bar in insert mode + let &t_EI = "\Ptmux;\\]50;CursorShape=0\x7\\\" " Block in normal mode +endif diff --git a/.zshrc b/.zshrc index 031ece0..65a63ec 100644 --- a/.zshrc +++ b/.zshrc @@ -138,16 +138,54 @@ precmd () { local git='$vcs_info_msg_0_' # Custom status line -PS1="[`hostname | sed 's/\..*//'`] $(active_virtualenv)${git}${fg_lblue}%~ ${fg_white}$ " +PS1="[`hostname | sed 's/\..*//'`] $(active_virtualenv)${git}${fg_lblue}%~ ${fg_white}" + +# Show a different cursor for different vim modes +function zle-keymap-select zle-line-init +{ + # change cursor shape in iTerm2 + if [[ $TMUX != "" ]] + then + case $KEYMAP in + vicmd) print -n -- "\033Ptmux;\033\E]50;CursorShape=0\C-G\033\\";; # block cursor + viins|main) print -n -- "\033Ptmux;\033\E]50;CursorShape=1\C-G\033\\";; # line cursor + esac + else + case $KEYMAP in + vicmd) print -n -- "\E]50;CursorShape=0\C-G";; # block cursor + viins|main) print -n -- "\E]50;CursorShape=1\C-G";; # line cursor + esac + fi -# Show a green $ on the status line when vim mode is -- INSERT -- -function zle-line-init zle-keymap-select { - PS1="[`hostname | sed 's/\..*//'`] $(active_virtualenv)${git}${fg_lblue}%~ ${fg_lgreen}${${KEYMAP/vicmd/}/(main|viins)/$}${fg_white}${${KEYMAP/vicmd/$}/(main|viins)/}${fg_white} " zle reset-prompt + zle -R } + +function zle-line-finish +{ + if [[ $TMUX != "" ]] + then + print -n -- "\033Ptmux;\033\E]50;CursorShape=0\C-G\033\\" + else + print -n -- "\E]50;CursorShape=0\C-G" + fi +} + zle -N zle-line-init +zle -N zle-line-finish zle -N zle-keymap-select +# # 10ms for key sequences +KEYTIMEOUT=1 + +# init cursor, apparently only needed for tmux, but left the conditional for consistency +if [[ $TMUX != "" ]] +then + print -n -- "\033Ptmux;\033\E]50;CursorShape=0\C-G\033\\" +else + print -n -- "\E]50;CursorShape=0\C-G" +fi + # ----------------------------------------------- # Set up zsh-specifics # -----------------------------------------------