fix(tmux): macOS clipboard, C-a passthrough, vim detection
- y/p use pbcopy/pbpaste (xsel is X11, absent on macOS); xsel kept as the Linux variant in a comment
- bind C-a send-prefix: C-a C-a sends a literal C-a to the shell
- is_vim reads #{pane_current_command}; the @tmux_vim_<pane> variable was never set, so C-h/j/k/l never reached vim
This commit is contained in:
@@ -43,12 +43,11 @@ set -g set-titles-string '#S :: #W :: #F#P #{pane_current_command}'
|
||||
# Variables: {{{
|
||||
# ---------
|
||||
|
||||
is_vim='tmux show -v "@tmux_vim_#{pane_id}" | grep yes' # check if is vim
|
||||
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
|
||||
# is_vim Note: {{{
|
||||
# vim is actually changing values of a variable to make it visible by tmux.
|
||||
# Without this, tmux would have to grep the current pane to see what is
|
||||
# running. ex:
|
||||
# echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"
|
||||
# The pane's foreground command, as tmux sees it. The older variant read a
|
||||
# "@tmux_vim_<pane>" variable that a vim plugin had to set; nothing sets it
|
||||
# here, so C-h/j/k/l never reached vim.
|
||||
# }}}
|
||||
|
||||
resurrect_root_dir="$XDG_CACHE_HOME/tmux/resurect"
|
||||
@@ -114,6 +113,7 @@ unbind-key -T copy-mode-vi MouseDragEnd1Pane # (mouse setting) {{{
|
||||
# }}}
|
||||
|
||||
set -g prefix C-a # bind screen like prefix
|
||||
bind C-a send-prefix # C-a C-a = literal C-a (shell home)
|
||||
|
||||
# specific commands
|
||||
bind-key C-o command-prompt "new-session -s %1 -c ~"
|
||||
@@ -136,16 +136,13 @@ bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
|
||||
|
||||
bind Escape copy-mode # bind vi-like 'normal' mode
|
||||
bind -Tcopy-mode-vi 'v' send -X begin-selection # bind vi-like visual mode
|
||||
bind -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "xsel -b -i" # xsel copy
|
||||
bind p run "xsel -b -o | tmux load-buffer - ; tmux paste-buffer" # xsel paste
|
||||
bind -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "pbcopy" # macOS copy
|
||||
bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer" # macOS paste
|
||||
# bind vi-like copy/paste through 'normal' mode, (Note) {{{
|
||||
# It is encouraged to use xsel instead of xclip, because xclip does not close
|
||||
# STDOUT after it has read from tmux's buffer. As such, tmux doesn't know
|
||||
# that the copy task has completed, and continues to wait for xclip's
|
||||
# termination, thereby rendering tmux unresponsive.
|
||||
# Here an example of copy paste with pbcopy/pbpaste (macos)
|
||||
# bind -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "pbcopy"
|
||||
# bind p run "pbpaste | tmux load-buffer - ; tmux paste-buffer"
|
||||
# Linux (X11) variant, xsel rather than xclip: xclip does not close STDOUT
|
||||
# after reading tmux's buffer, so tmux waits for it and hangs.
|
||||
# bind -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel "xsel -b -i"
|
||||
# bind p run "xsel -b -o | tmux load-buffer - ; tmux paste-buffer"
|
||||
# }}}
|
||||
bind-key -Tcopy-mode-vi Escape send -X cancel # cancel v mode
|
||||
bind-key -Tcopy-mode-vi ^v send -X rectangle-toggle # cancel v mode
|
||||
|
||||
Reference in New Issue
Block a user