iTerm2 has tmux integration which I don't care for, this integration
mucks up using tmux as the shell for a profile. To work around this, the
`visor.zsh` script is used in the _Send text at start_ for the a Quake
style visor profile as follows:
```
source ~/.config/tmux/visor.zsh
```
For pagers such as `less` which don't support terminal mouse features
enable scrolling with the mouse wheel by emulating the behaviour using
`send-keys -t= {up,down}` when in alternate (fullscreen) mode.
These bindings retain the expected behaviour when using programs which
do support terminal mouse events and copy-mode.
Sometimes when yanking large blocks of text from a pane larger than its
size in copy mode did not work. Switch to using `xclip` from `xsel` to
see if this works better.
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.