Skip to content

Commit

Permalink
Add quetty doc
Browse files Browse the repository at this point in the history
  • Loading branch information
deanstag committed Oct 11, 2020
1 parent 572da25 commit 848a639
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ sending the output to your system clipboard or anywhere you want it to be. They

### Other helper scripts ###
#### quetty ####
[quetty](docs/QUETTY.md)

quetty is the default SELECTOR used. quetty filters the input and dumps out strings that matches the specified regexes and custom filters. It has a few inbuilt tokenizers like

hash - hash values
Expand Down Expand Up @@ -201,6 +203,11 @@ FILTER - xargs scripts/snippetdb get
# Fetch the valye of the given key
```

To use the snippets mode, keep adding useful snippets.
```
echo git commit | scripts/snippetdb put gc
```

Related projects
------------------

Expand All @@ -211,6 +218,10 @@ Why tmux-butler instead of extrakto? The tmux-butler tokenizer is also written i

- [tmux-thumbs](https://github.com/fcsonline/tmux-thumbs) and [tmux-fingers](https://github.com/Morantron/tmux-fingers) for hint based selection

Contributing
----------
tmux-butler was made to be easily added upon with more powerful scripts. Feel free to contribute and send pull requests.

[License](LICENSE)
------------------

Expand Down
49 changes: 49 additions & 0 deletions docs/QUETTY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
quetty
-----------
quetty is a script that filters/tokenizes the standard input based on the options provided.
The filters can be predefined, regular expressions specified using the `-regex` flag, or a custom flag specified using `-custom`. Multiple filters can be provided and the final list of tokens will be an OR of all the filters.

#### Predefined
- hash - hash values
- ip - ip addresses and ip prefixes
- nospace - strings that match \S+
- num - numbers
- word - strings that match \w+
- path - filesystem path like strings
- quote - entire single and double quoted strings

eg: To filter out ip addressess and paths from standard input
```
scripts/quetty -path -ip
```


#### Custom regular expressions
In addition to these, user can provide custom filters by using the `-regex` flag.
eg: To filter only words that start with the character 'a',
```
scripts/quetty -regex 'a\w*'
```

#### Custom filters
In addition to specifying custom regexes using the `-regex` flag, you can write more detailed filters using bash scripts in the `filters/` directory. The name of the filter can be anything BUT the predefined filters mentioned above.

For each filter specified, quetty passes the input through the filter script and saves the output to be later sorted and uniqued.

`-path` is a custom filter. Take a look at the `fitlers/path` script for a simple custom filter implementation.


A simpler example: To filter only words that start with the character 'b', create a file `filters/bword` with the following contents.
```
#!/usr/bin/env bash
# the -o will make sure that only the matched tokens are printed out and not the entire line
egrep -o 'b\w+'
```
Make sure it is executable
```
chmod +x filters/bword
```
To use this filter
```
scripts/quetty -bword
```

0 comments on commit 848a639

Please sign in to comment.