tmux-plugins / tmux-copycat

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

Search incorrect with multi-line prompt #102

Closed CeleritasCelery closed 7 years ago

CeleritasCelery commented 7 years ago

If the shell prompt is more than one line the search functionality does not work correctly and matches on the wrong line.

For example if my prompt in tcsh is

set prompt="%{\033[34m%}[%h][%~]\n%#%{\033[0m%} "

which would display as

[command-number][/current/working/directory]
>  

When I initiate a search, the match highlighted is a group of characters that are directly above the desired string. If my prompt was three lines instead of two, the match highlighted would be two lines above the search string and so forth. When yanking with tmux-yank, it grabs the incorrect characters from the offset line.

CeleritasCelery commented 7 years ago

Since it would appear that this plugin is no longer maintained I will provide the answer I found here for anyone else curious. This is a problem only effecting C-Shell and not Bash. The solution is to change this line to add an offset for the size of your prompt. For example if your shell prompt 3 lines long (two more then normal) you would change this line to local line_numbers=$($1 - 2) and so forth. As for my self I created a new variable @copycat_prompt_lines that I could add to my tmux.conf which would allow me to change this dynamically.

However I found a better solution to multi-line prompts is to just use the precmd alias and print out what you want before displaying the prompt. Much cleaner.