Can I use double click to select and copy in tmux?

前端 未结 6 1140
天涯浪人
天涯浪人 2021-02-01 04:04

I am learning to use tmux, I found when I in a tmux window, double-click to select and copy function did not work any more.

Can I use double-click to select and copy jus

6条回答
  •  北恋
    北恋 (楼主)
    2021-02-01 04:57

    Don't know about iterm2, but this can be made to work in tmux 3.0 or newer
    (tested on Linux w/ tmux 3.0, last command uses X11 xclip).

    Added triple click to select and copy a line too.

    # Double LMB Select & Copy (Word)
    bind-key -T copy-mode-vi DoubleClick1Pane \
        select-pane \; \
        send-keys -X select-word-no-clear \; \
        send-keys -X copy-pipe-no-clear "xclip -in -sel primary"
    bind-key -n DoubleClick1Pane \
        select-pane \; \
        copy-mode -M \; \
        send-keys -X select-word \; \
        send-keys -X copy-pipe-no-clear "xclip -in -sel primary"
    
    # Triple LMB Select & Copy (Line)
    bind-key -T copy-mode-vi TripleClick1Pane \
        select-pane \; \
        send-keys -X select-line \; \
        send-keys -X copy-pipe-no-clear "xclip -in -sel primary"
    bind-key -n TripleClick1Pane \
        select-pane \; \
        copy-mode -M \; \
        send-keys -X select-line \; \
        send-keys -X copy-pipe-no-clear "xclip -in -sel primary"
    

    If you don't use copy-mode-vi, replace this with copy-mode.


    For older tmux versions check the edit-history.

提交回复
热议问题