Closed bruno- closed 10 years ago
After looking into this, I have no idea how could this be improved..
Currently users can define "stored searches" by having something like this in .tmux.conf
:
set -g "@copycat" "C-x|my_regex_search"
The above will create a binding prefix + C-x
that will perform a search. The same mechanism is used for builtin searches eg prefix + C-f
, prefix + C-u
etc...
The idea was to improve it by leveraging tmux variable appending, but that is broken in tmux:
tmux set -g "@var" "foo"
tmux set -ag "@var" "bar" # appending "bar" to the variable
tmux show -g "@var" # => "bar", but should be "foobar"
Ok, now that I understand how it works, it is not that bad.
Indeed set -a
does not work for user-options, so there might not be any necessity to improve anything. Worst case scenario, it remains possible to tmux set -ag @copycat "$(tmux show -gvq @copycat) foo"
to append to an existing (or not) var.
What is needed is the documentation for the various tmux options that copycat uses. I'll try to add this and create a PR tonight.
This is a good idea:
tmux set -g @copycat "$(tmux show -gvq @copycat) foo"
Another option for handling user defined searches would be to introduce a new variable eg @copycat_searches
. @copycat
variable can stay the same for "plugin defined" searches.
The thing that gives me pause about both approaches is that user defined regex could quickly become messy. Example:
# users `tmux.conf
set -g @copycat "C-x|my_stored_search_regex_that_is_long_and_messy C-z|another_stored_search_that_makes_the_line_too_long"
Anyway, if you get any idea for this, I'd be glad to hear it. On the other hand, there's no need to rush with implementation...
Well it is always possible to write:
set -g @copycat " \
C-x|my_stored_search_regex_that_is_long_and_messy \
C-z|another_stored_search_that_makes_the_line_too_long \
etc."
Improve the way copycat handles stored regex searches