From 68ad145b3884158a0fc04f0c506e11c12dd43a18 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 9 Feb 2023 10:09:15 +0000 Subject: tmux: split some config parts into multiple parts --- %HOME%/.config/tmux/cygwin.conf | 7 +++++++ %HOME%/.config/tmux/linux.conf | 19 ++++++++++++++++++ %HOME%/.config/tmux/macos.conf | 7 +++++++ %HOME%/.tmux.conf | 43 ++++------------------------------------- 4 files changed, 37 insertions(+), 39 deletions(-) create mode 100644 %HOME%/.config/tmux/cygwin.conf create mode 100644 %HOME%/.config/tmux/linux.conf create mode 100644 %HOME%/.config/tmux/macos.conf (limited to '%HOME%') diff --git a/%HOME%/.config/tmux/cygwin.conf b/%HOME%/.config/tmux/cygwin.conf new file mode 100644 index 0000000..3c9f14a --- /dev/null +++ b/%HOME%/.config/tmux/cygwin.conf @@ -0,0 +1,7 @@ +bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard' +bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux paste-buffer' +bind-key -T copy-mode-vi M-y send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard; tmux paste-buffer' +bind-key -T copy-mode-vi '!' send-keys -X copy-pipe-and-cancel "tr -d '\n' > /dev/clipboard" +bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard' +bind-key -T root MouseDown2Pane run 'cat /dev/clipboard | tmux load-buffer - && tmux paste-buffer' +bind-key ] run 'cat /dev/clipboard | tmux load-buffer - && tmux paste-buffer' diff --git a/%HOME%/.config/tmux/linux.conf b/%HOME%/.config/tmux/linux.conf new file mode 100644 index 0000000..ed4800a --- /dev/null +++ b/%HOME%/.config/tmux/linux.conf @@ -0,0 +1,19 @@ +# Depends on xsel. + +# The simple +# +# xsel -i --clipboard +# +# doesn't work, but +# +# xsel -i -p && xsel -o -p | xsel -i -b +# +# does[1]. How fun! + +bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b' +bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux paste-buffer' +bind-key -T copy-mode-vi M-y send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b; tmux paste-buffer' +bind-key -T copy-mode-vi '!' send-keys -X copy-pipe-and-cancel "tr -d '\n' | xsel -i -p && xsel -o -p | xsel -i -b" +bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b' +bind-key -T root MouseDown2Pane run 'xsel -o | tmux load-buffer - && tmux paste-buffer' +bind-key ] run 'xsel -o | tmux load-buffer - && tmux paste-buffer' diff --git a/%HOME%/.config/tmux/macos.conf b/%HOME%/.config/tmux/macos.conf new file mode 100644 index 0000000..abbe020 --- /dev/null +++ b/%HOME%/.config/tmux/macos.conf @@ -0,0 +1,7 @@ +bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'pbcopy' +bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux paste-buffer' +bind-key -T copy-mode-vi M-y send-keys -X copy-pipe-and-cancel 'pbpaste; tmux paste-buff' +bind-key -T copy-mode-vi '!' send-keys -X copy-pipe-and-cancel "tr -d '\n' | pbcopy" +bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'pbcopy' +bind-key -T root MouseDown2Pane run 'pbpaste | tmux load-buffer - && tmux paste-buffer' +bind-key ] run 'pbpaste | tmux load-buffer - && tmux paste-buffer' diff --git a/%HOME%/.tmux.conf b/%HOME%/.tmux.conf index 21db6d6..c6d0fb6 100644 --- a/%HOME%/.tmux.conf +++ b/%HOME%/.tmux.conf @@ -106,45 +106,10 @@ bind-key -T copy-mode-vi v send -X begin-selection # M-y is y and Y combined. # ! to copy excluding line endings (most useful for one-line selections). -# 1. Cygwin - -if-shell 'uname | grep -q -F CYGWIN' { - bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard' - bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux paste-buffer' - bind-key -T copy-mode-vi M-y send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard; tmux paste-buffer' - bind-key -T copy-mode-vi '!' send-keys -X copy-pipe-and-cancel "tr -d '\n' > /dev/clipboard" - bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'cat > /dev/clipboard' - bind-key -T root MouseDown2Pane run 'cat /dev/clipboard | tmux load-buffer - && tmux paste-buffer' - bind-key ] run 'cat /dev/clipboard | tmux load-buffer - && tmux paste-buffer' -} - -# 2. Linux - -# Depends on xsel. -# The simple `xsel -i --clipboard` doesn't work, but `xsel -i -p && xsel -o -p -# | xsel -i -b` [1] does. How fun! - -if-shell 'uname | grep -q -F Linux && which xsel' { - bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b' - bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux paste-buffer' - bind-key -T copy-mode-vi M-y send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b; tmux paste-buffer' - bind-key -T copy-mode-vi '!' send-keys -X copy-pipe-and-cancel "tr -d '\n' | xsel -i -p && xsel -o -p | xsel -i -b" - bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xsel -i -p && xsel -o -p | xsel -i -b' - bind-key -T root MouseDown2Pane run 'xsel -o | tmux load-buffer - && tmux paste-buffer' - bind-key ] run 'xsel -o | tmux load-buffer - && tmux paste-buffer' -} - -# 3. macOS - -if-shell 'uname | grep -q -F Darwin' { - bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'pbcopy' - bind-key -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel 'tmux paste-buffer' - bind-key -T copy-mode-vi M-y send-keys -X copy-pipe-and-cancel 'pbpaste; tmux paste-buff' - bind-key -T copy-mode-vi '!' send-keys -X copy-pipe-and-cancel "tr -d '\n' | pbcopy" - bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'pbcopy' - bind-key -T root MouseDown2Pane run 'pbpaste | tmux load-buffer - && tmux paste-buffer' - bind-key ] run 'pbpaste | tmux load-buffer - && tmux paste-buffer' -} +if-shell 'uname | grep -q -F CYGWIN' source-file ~/.config/tmux/cygwin.conf +if-shell 'uname | grep -q -F Linux && command -v xsel' \ + source-file ~/.config/tmux/linux.conf +if-shell 'uname | grep -q -F Darwin' source-file ~/.config/tmux/macos.conf # Appearance # ---------- -- cgit v1.2.3