UP | HOME

Date: [2022-11-19 Sat]

Tmux

Table of Contents

1. Copy to system clipboard

https://dev.to/iggredible/the-easy-way-to-copy-text-in-tmux-319g

C-b : list-keys command lists the current keybindings of tmux

Add these lines to your ~/.tmux.conf and tmux will now copy text to system clipboard too. This basically overrides the default copy keypresses (MouseDragEnd, C-w, M-w) to send the copied text to pbcopy.

< Collapse code block> Expand code block
bind -T copy-mode C-w send-keys -X copy-pipe-and-cancel "pbcopy"
bind -T copy-mode M-w send-keys -X copy-pipe-and-cancel "pbcopy"
bind -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
bind -T copy-mode C-k                  send-keys -X copy-pipe-end-of-line-and-cancel "pbcopy"
bind -T copy-mode DoubleClick1Pane     select-pane \; send-keys -X select-word \; run-shell -d 0.3 \; send-keys -X copy-pipe-and-cancel "pbcopy"
bind -T copy-mode TripleClick1Pane     select-pane \; send-keys -X select-line \; run-shell -d 0.3 \; send-keys -X copy-pipe-and-cancel "pbcopy"
bind -T root DoubleClick1Pane select-pane -t = \; if-shell -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" { send-keys -M } { copy-mode -H ; send-keys -X select-word ; run-shell -d 0.3 ; send-keys -X copy-pipe-and-cancel "pbcopy" }
bind -T root TripleClick1Pane select-pane -t = \; if-shell -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" { send-keys -M } { copy-mode -H ; send-keys -X select-line ; run-shell -d 0.3 ; send-keys -X copy-pipe-and-cancel "pbcopy" }

You can send your feedback, queries here