CLI: How to quickly select and copy any text with TMUX — no plugin required
Introduction
Older versions in TMUX required using both tmux-copycat and tmux-yank plugins.
There is an simpler solution as from TMUX 3.1 native regex search is included natively. Also from 1.5 yank works out of the box.
Although I still use tmux-yank and tmux-copycat, I believe nowadays there’s no need to have them installed unless you need specific features included in those two plugins.
How To
TIP
Use the q to exit the copy mode
Search
To search for words the combination you need to use is a bit tricky to learn, but once you have mastered it, you will find it works well.
To enable copy mode first add the following to your tmux configuration file.
setw -g mode-keys vi
- Enter Copy Mode by hitting
Prefix + [ - Enable search hitting
/then type the text you would like to search - Hit
Enter - Press
n(from next) to navigate to the next selection
Select
- Enter Copy Mode by
Prefix + [ - Hit
space - Use the arrows or vim keys (
h,j,k,l) if enabled to select - Hit Enter or
qto exit
Yank/Copy
Do either of previous steps and then
- Hit
y - After hitting
yyou will enter to normal mode and the text will be on your clipboard. - Try to paste it by using
Ctrl + vorCommand + v.