tmux-plugins / tmux-copycat

A plugin that enhances tmux search
MIT License
1.1k stars 63 forks source link

Use native regex searches in tmux 3.2 #148

Closed toupeira closed 4 years ago

toupeira commented 4 years ago

Native regex search was added in the recently released tmux 3.1: https://github.com/tmux/tmux/issues/2178

tmux 3.2 will also make it possible to copy the current match with copy-selection (see discussion in that issue), so at that point I think tmux-copycat can be greatly simplified and basically turn into a (still very useful!) collection of default keybindings and search patterns.

Some considerations:

bruno- commented 4 years ago

This is great news. Native regex support will be much faster and better implemented I'm sure.

As for the transition: I think we can leave this plugin as-is. Maybe it will be useful to some users stuck on older tmux versions. We can add a note to the README about new tmux features.

As for the useful parts: we can create a new, much smaller plugin for that.

bruno- commented 4 years ago

A note about tmux's native regex support has been added to the readme.

toupeira commented 4 years ago

@bruno- thanks, sounds good to me! :+1: Feel free to close this issue.

I played around with the native regex search a bit, it is indeed much faster and supports the same extended regex syntax, so I could just reuse the patterns from tmux-copycat. But I ran into a problem with moving between matches which is being discussed in https://github.com/tmux/tmux/issues/2301, so at the moment I'm still using this plugin.

bruno- commented 4 years ago

Yes, I think this plugin still has some extra features. Once tmux natively implements search highlighting (search match selection) it will become obsolete.

@toupeira do you want to work on a copycat replacement plugin?

Drowze commented 2 years ago

I know this is closed, but I'd like to leave the config I've been using on 3.2 instead of tmux-copycat and tmux-yank for anyone who's curious to try (inspired by this issue):

# Copy selection with y
bind-key -T copy-mode-vi y send -X copy-selection-no-clear

# Search backwards with prefix-/
bind / copy-mode \; send ?

# Somewhat tmux-copycat select url functionality (requires 3.1+)
bind C-u copy-mode \; send -X search-backward "(https?://|git@|git://|ssh://|ftp://|file:///)[[:alnum:]?=%/_.:,;~@!#$&()*+-]*"
toupeira commented 2 years ago

@toupeira do you want to work on a copycat replacement plugin?

Oh I also forgot to respond to this, I guess a plugin feels like overkill if it's just a bunch of regex patterns, and it becomes more complicated to customize the plugin rather than just writing your own mappings :grinning:

But I've been happily using the native regex search too, with these mappings:

https://github.com/toupeira/dotfiles/blob/503b929d30980d549ebef8d6da522d36b13d6e1e/tmux.conf#L161-L167

And this helper script:

https://github.com/toupeira/dotfiles/blob/503b929d30980d549ebef8d6da522d36b13d6e1e/tmux/scripts/search#L1-L41