tmux-thumbs icon indicating copy to clipboard operation
tmux-thumbs copied to clipboard

Regexes in Tmux config

Open nyarly opened this issue 5 months ago • 3 comments

I'm having some issues getting regexes to match in thumbs - it seems like the issue is that tmux is escaping parts of the regex, which breaks the match.

For instance, if I try to add

set -g @thumbs-regexp-1 '\["[[:alnum:]]+"\]'

(this is a sub-RE if what I actually want - Terraform module names...) that doesn't work.

tmux show -g indicates displays:

@thumbs-regexp-1 '\\["[[:alnum:]]+"\\]'

In other words, it looks like the \ gets itself escaped, which blocks the match.

nyarly avatar Jun 10 '25 18:06 nyarly

@fcsonline Are you still interested in maintaining this repo? I notice that PRs are growing and last commit is > 2 years ago.

nyarly avatar Jun 10 '25 18:06 nyarly

Found the cause: https://github.com/fcsonline/tmux-thumbs/blob/ae91d5f7c0d989933e86409833c46a1eca521b6a/src/swapper.rs#L158

The options regexp matches [^"]+ for values, so no regular expression with a '"' will match.

nyarly avatar Jun 12 '25 22:06 nyarly

https://xkcd.com/234/

The workaround for now is to use \x22 instead of ", but a more robust solution would be appreciated I think.

nyarly avatar Jun 12 '25 23:06 nyarly