Make using the `@vim$TMUX_PANE` window flag much more robust by
unsetting it every time the zsh prompt is drawn and setting it again
using a `FocusGained` `autocmd` in vim. This removes the need for the
hacky check for zsh in the conditional defined in the `in_vim` variable.
Fixes#6 by setting a window option called `vim$TMUX_PANE` during vim
setup, and removing it when vim exits:
```vim
if $TMUX !=# ''
" Set tmux window option to detect when to change pane.
let s:tmux_option = '@vim'.substitute($TMUX_PANE, '%', '\\%', 'g')
call system('tmux set-window-option '.s:tmux_option.' 1')
au VimLeave * call system('tmux set-window-option -u '.s:tmux_option)
endif
```
Then update the `is_vim` conditional shell statement to check if this
variables exists for the current pane to determine when to change tmux
pane or pass through the binding to vim.
```conf
in_vim='[[ "$(tmux show-window-options)" = *"@vim#{pane_id}"* ]] && \
[[ "#{pane_current_command}" != zsh ]]'
```
Additionally check if the vim task has been backgrounded by comparing
the value of `#{pane_current_command}`, this is likely a bit brittle if
backgrounding is used heavily but works otherwise.
Use iTerm2 proprietary escape sequence for changing cursor shape per
pane. Apps like vim or zsh should emit VTE compatible escape sequences
for this to work.