brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: * in tmux copy mode searches for the word under the cursor

Tmux
~/tips/tip-tmux-copy-mode-star-search

Ctrl-b [

Finds the next place a word appears without typing it.

In vi copy mode, tmux borrows a Vim habit: put the cursor on a word and press * to find its next occurrence in the scrollback.

Ctrl-b [
*
n

Enter copy mode, move onto a word such as a hostname or an error code, and press *. tmux searches downwards for that word and jumps to the next match. # does the same upwards, which is usually what I want in a log, because the older lines are above. After that, n repeats the search and N goes the other way.

Under the hood it is search-forward with the format #{copy_cursor_word}, so you could bind it to other keys if you like:

bind -T copy-mode-vi C-f send -FX search-forward "#{copy_cursor_word}"

These bindings only exist in the vi key table, so you need set -g mode-keys vi. They also arrived in fairly recent versions; on an older tmux the keys do nothing, and the / and ? searches are the way to go.

What counts as a word follows the word-separators option. With the default on recent versions, which includes punctuation, a path like /var/log/syslog is several words, so * on it searches only for the part under the cursor.

Further reading: tmux manual page (OpenBSD)

More Tmux tips tmux new -d -s report -x 200 -y 50 'top' tmux wait-for build-done set -g allow-passthrough on tmux kill-server Ctrl-b [ All Tmux tips (125) All topics

Link