diff --git a/README.md b/README.md index bfea4fe..74f091c 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ press the caps version of the key hint (for instance E instead of e), or first toggle the destination buffer with the space key and press the hint with no caps. -You can also use the n and p (or Up and +You can also use the n and N (or Up and Down) keys to move focus across the highlighted spans. Press y to yank the focused span into the tmux buffer, or press Y to yank it into the system clipboard. @@ -51,7 +51,7 @@ go back to the first span. ### Matched patterns and default key-bindings tmux-copyrat can match one or more pre-defined (named) patterns, but you can -add your own too. +add your own too (see [CONFIGURATION.md]). The default configuration provided in the [`copyrat.tmux`](copyrat.tmux) plugin file provides the following key-bindings. Because they all start with @@ -72,7 +72,7 @@ should type prefix + t + u. | P | Hex numbers and pointer addresses | `pointer-address` | | | strings inside single quotes | `quoted-single` | | | strings inside double quotes | `quoted-double` | -| | strings inside backticks | `quoted-tick` | +| | strings inside backticks | `quoted-backtick` | | q | strings inside single/double/backticks | | | u | URLs | `url` | | U | UUIDs | `uuid` | @@ -81,16 +81,12 @@ should type prefix + t + u. | 6 | IPv6 addresses | `6` | | space | All patterns | | -If you want additional patterns, you can provide them via the -`--custom-pattern` command line option (short option: `-X`), see -[CONFIGURATION.md]. - ## The `copyrat` companion executable The central binary of this crate is `tmux-copyrat`, however there is also the -`copyrat` executable. It simply provides the same functionality, without any -tmux dependency or integration. +`copyrat` executable which provides the same functionality minus any tmux +dependency or integration and instead reads from stdin. You can use `copyrat` to search a span of text that you provide to stdin. @@ -98,8 +94,8 @@ For instance here is a bunch of text, with dates and git hashes which you can search with copyrat. ```console -$ echo -n '* e006b06 - (12 days ago = 2021-03-04T12:23:34) e006b06 e006b06 swapper: Make quotes\n/usr/local/bin/git\n\nlorem\n/usr/local/bin\nlorem\n/usr/local/bin/git\n* e006b06 - (12 days ago = 2021-03-04T12:23:34) e006b06 e006b06 swapper: Make quotes' \ - | ./target/release/copyrat -r --unique-hint -s bold -X '(loca)' -x sha datetime +$ echo -n '* e006b06 - (12 days ago = 2021-03-04T12:23:34) e006b06 e006b06 swapper: Make quotes\n/usr/local/bin/git\n\nlorem\n/usr/local/bin\nlorem\nThe error was `Error no such file`\n/usr/local/bin/git' \ + | ./target/release/copyrat -r --unique-hint -s bold -X '(loca)' -x sha datetime quoted-backtick ``` You will see the following in your terminal @@ -107,7 +103,12 @@ You will see the following in your terminal ![[copyrat-output.png](images/copyrat-output.png)](images/copyrat-output.png) You may have noticed that all identical spans share the same _hint_, this is -due to the `-unique-hint` option (`-u`). The hints are in bold text, due to the `--hint-style bold` option (`-s`). +due to the `-unique-hint` option (`-u`). The hints are in bold text, due to the +`--hint-style bold` option (`-s`). Hints start from the bottom, due to the +`--reverse` option (`-r`). A custom pattern was provided for matching any +"loca", due to the `--custom-regex-pattern` option (`-X`). The sha, datetime +and content inside backticks were highlighted due to the `--named-pattern` +option (`-x`). ## Tmux compatibility diff --git a/copyrat.tmux b/copyrat.tmux index 98cdfa6..68d131f 100755 --- a/copyrat.tmux +++ b/copyrat.tmux @@ -98,7 +98,7 @@ setup_pattern_binding "p" "--pattern-name path" # prefix + t + P searches for hex numbers: 0xbedead setup_pattern_binding "P" "--pattern-name pointer-address" # prefix + t + q searches for strings inside single|double|backticks -setup_pattern_binding "q" "-x quoted-single -x quoted-double -x quoted-tick" +setup_pattern_binding "q" "-x quoted-single -x quoted-double -x quoted-backtick" # prefix + t + u searches for URLs setup_pattern_binding "u" "--pattern-name url" # prefix + t + U searches for UUIDs diff --git a/images/copyrat-output.png b/images/copyrat-output.png index f6d34f6..2b8d020 100644 Binary files a/images/copyrat-output.png and b/images/copyrat-output.png differ diff --git a/src/textbuf/mod.rs b/src/textbuf/mod.rs index 86553c4..278ab96 100644 --- a/src/textbuf/mod.rs +++ b/src/textbuf/mod.rs @@ -584,7 +584,7 @@ mod tests { let named_pat = vec![ parse_pattern_name("quoted-single").unwrap(), parse_pattern_name("quoted-double").unwrap(), - parse_pattern_name("quoted-tick").unwrap(), + parse_pattern_name("quoted-backtick").unwrap(), ]; let custom = vec![]; diff --git a/src/textbuf/regexes.rs b/src/textbuf/regexes.rs index 7feb89a..43e0db2 100644 --- a/src/textbuf/regexes.rs +++ b/src/textbuf/regexes.rs @@ -42,7 +42,7 @@ pub(super) const PATTERNS: [(&str, &str); 20] = [ ), ("quoted-single", r#"'([^']+)'"#), ("quoted-double", r#""([^"]+)""#), - ("quoted-tick", r#"`([^`]+)`"#), + ("quoted-backtick", r#"`([^`]+)`"#), ("digits", r"([0-9]{4,})"), ];