tmux-copycat
tmux-copycat copied to clipboard
Discussion: ideas for stored searches
As described in the defining new stored searches doc, this plugin enables you to define your own, custom searches.
Let's tap into the community ideas and see what others came up with or are missing.
Use this thread to:
- share what "custom" searches you use (and in which situations)
- request for something you'd like to search but can't (or don't know how)
Interesting searches will be added to Useful searches section.
Get commit hash in git log
set -g @copycat_search_WHATEVER '^commit[[:space:]]*'
Amazon jobflow ID
set -g @copycat_search_C-j 'j-[[:alnum:]]*'
I have a stored search for quoted text:
set -g @copycat_search_C-q '\"[^\"]*\"'
Frequently filenames, error messages and other important info are quoted in a program's output.
However, I'm unable to match single quotes, even escaping doesn't work. Is this a bug or am I doing it wrong?
@AnAppAMonth, interesting idea. Thanks for the submission.
I think a single quote searches could have a bug! I also just tried it and got an error. Please open an issue with the description of what you tried. A pull request for this is also very welcome.
@ctjhoa improved the regex to match SHA1 hashes in every output format. See #73
Pull request for email address search over at #78
Get the last entry of a line if it is standard filename.
set -g @copycat_search_C-l '[a-zA-Z0-9_-./]+$'
This works for filenames without any path (basename - as for example for ls -l) and for git status if you are not in the root of the repo.
Often people have the pwd on their bash prompt like so (fish truncates all but the last paths to one letter):
endrebak@havpryd ~/c/c/workflows>
I'd like some way of avoiding those in the file search, but dunno if that is possible.
Can we have these searches in a way similar to vim-text-objects
? That would make it much easier to remember and increase the key-combination
space available to reduce clashes.
Match kubernetes objects
e.g. "asdf-gk8nr" or "asdf-foo-7bdcf85cf5-97x64"
set -g @copycat_search_C-k '[A-Za-z0-9-]+-[a-f0-9]{10}-[a-z0-9]{5}|[A-Za-z0-9-]+-[a-z0-9]{5}'
Match 32 bit or 64 bit addresses
e.g. "0xffffd53a", "0xffffd53affffd53a", "ffffd53a" or "ffffd53affffd53a"
set -g @copycat_search_a '0x[A-Fa-f0-9]{8}|0x[A-Fa-f0-9]{16}|[A-Fa-f0-9]{8}|[A-Fa-f0-9]{16}' # 32 or 64 bit adresses
The example here
set -g @copycat_search_G '\b[0-9a-f]{5,40}\b'
should be
set -g @copycat_search_G '\b[0-9a-f]{5}|[0-9a-f]{40}\b'
The search goes from bottom to top. Is there any way to search only the last command output (preferably from top to bottom)?
~~based on a quick search no. you would need to re-write or duplicate and change https://github.com/tmux-plugins/tmux-copycat/blob/master/scripts/copycat_generate_results.sh#L20~~
--
I guess you could use this somehow https://github.com/tmux-plugins/tmux-copycat/blob/master/scripts/copycat_jump.sh#L231 Use get_number_of_results to set initial jump position.
The "last entry" file search didn't work for me. The order of the regex was causing an issue:
set -g @copycat_search_C-f '[a-zA-Z0-9_./-]+$'
For the future reader, here's the issue reporting the single quote breakage.
I was not able to get the quoting snippet to work:
set -g @copycat_search_C-q "\"[^\"]*\""
It always selected the quotes incorrectly for me (if anyone knows why, I'd love to hear it):
@iloveitaly looks like you are on a mac. Maybe you are not using GNU grep?
$ grep --version
grep (GNU grep) 3.11
Packaged by Homebrew
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others; see
<https://git.savannah.gnu.org/cgit/grep.git/tree/AUTHORS>.
grep -P uses PCRE2 10.42 2022-12-11
@iloveitaly I am on a mac, but changing the default grep
installation would be a large-ish change since many other applications rely on the terrible grep
version installed by default.
@iloveitaly
if you are on an M1 chip just do
export PATH=/opt/homebrew/opt/grep/libexec/gnubin/grep:$PATH"
on an x86-64 bit machine do
export PATH=/usr/local/opt/grep/libexec/gnubin:$PATH"
you can check what to export at
$ brew info grep
==> grep: stable 3.11 (bottled), HEAD
GNU grep, egrep and fgrep
https://www.gnu.org/software/grep/
/opt/homebrew/Cellar/grep/3.11 (19 files, 1MB) *
Poured from bottle using the formulae.brew.sh API on 2023-07-04 at 11:37:53
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/grep.rb
License: GPL-3.0-or-later
==> Dependencies
Build: pkg-config (installed)
Required: pcre2 (installed)
==> Options
--HEAD
Install HEAD version
==> Caveats
All commands have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"