1
0
Fork 0
mirror of synced 2024-05-26 20:11:09 -04:00

added tmux_conf_copy_to_os_clipboard variable, closes #75

When true, copying selection with y in copy mode also sends selection to the OS
clipboard.
This commit is contained in:
Gregory Pakosz 2017-05-17 22:23:23 +02:00
parent 785ba173a3
commit 264a577ba1
2 changed files with 45 additions and 3 deletions

View file

@ -131,8 +131,14 @@ run -b 'tmux bind -T copy-mode-vi Escape send -X cancel 2> /dev/null || true'
run -b 'tmux bind -t vi-copy H start-of-line 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi L send -X end-of-line 2> /dev/null || true'
# copy to Mac OSX pasteboard
if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy"'
# copy to Mac OSX clipboard
if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | reattach-to-user-namespace pbcopy"'
# copy to X11 clipboard
if -b 'command -v xsel > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xsel -i -b"'
if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xclip -i -selection clipboard >/dev/null 2>&1"'
# copy to Windows clipboard
if -b 'command -v clip.exe > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | clip.exe"'
if -b '[ -c /dev/clipboard ]' 'bind y run -b "tmux save-buffer - > /dev/clipboard"'
# -- user defined overrides ----------------------------------------------------
@ -618,6 +624,34 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# else
# tmux bind + display 'your tmux version has a buggy swap-pane command - see ticket #108, fixed in upstream commit 78e783e'
# fi
#
# tmux_conf_copy_to_os_clipboard=${tmux_conf_copy_to_os_clipboard:-false}
# if _is_enabled "$tmux_conf_copy_to_os_clipboard"; then
# if command -v pbcopy > /dev/null 2>&1; then
# tmux bind -t vi-copy y copy-pipe 'pbcopy' 2> /dev/null || true
# tmux bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'pbcopy' 2> /dev/null || true
# fi
# if command -v reattach-to-user-namespace > /dev/null 2>&1; then
# tmux bind -t vi-copy y copy-pipe 'reattach-to-user-namespace pbcopy' 2> /dev/null || true
# tmux bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy' 2> /dev/null || true
# fi
# if command -v xsel > /dev/null 2>&1; then
# tmux bind -t vi-copy y copy-pipe 'xsel -i -b' 2> /dev/null || true
# tmux bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'xsel -i -b' 2> /dev/null || true
# fi
# if ! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1; then
# tmux bind -t vi-copy y copy-pipe 'xclip -i -selection clipboard > /dev/null 2>&1' 2> /dev/null || true
# tmux bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -i -selection clipboard > /dev/null 2>&1' 2> /dev/null || true
# fi
# if command -v clip.exe > /dev/null 2>&1; then
# tmux bind -t vi-copy y copy-pipe 'clip.exe' 2> /dev/null || true
# tmux bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'clip.exe' 2> /dev/null || true
# fi
# if [ -c /dev/clipboard ] > /dev/null 2>&1; then
# tmux bind -t vi-copy y copy-pipe 'cat > /dev/clipboard' 2> /dev/null || true
# tmux bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'cat > /dev/clipboard' 2> /dev/null || true
# fi
# fi
# }
#
# _apply_theme() {

View file

@ -229,7 +229,15 @@ tmux_conf_theme_clock_colour='#00afff' # light blue
tmux_conf_theme_clock_style='24'
# ------------------------------------------------------------------------------
# -- clipboard -----------------------------------------------------------------
# in copy mode, copying selection also copies to the OS clipboard
# - true
# - false (default)
tmux_conf_copy_to_os_clipboard=false
# -- user customizations -------------------------------------------------------
# this is the place to override or undo settings
# increase history size