ohk, an interactive replacement to tools like grep and awk
Features:
- Normal / fuzzy / regex search for lines
- Case sensitive / insensitive search
- Keyboard shortcuts
Installation
→ pip install git+https://github.com/kbairak/ohk
or
→ git clone https://github.com/kbairak/ohk
→ cd ohk
→ pip install .
Add sudo or --user to your pip install command depending on your setup
Usage
→ [previous command | ] ohk [-f / -r / -i] [ | next command]
The previous command's output will be piped into ohk which will start an
interactive session to help you filter its lines and columns. Once you press
enter inside the interactive session, the filtered output will piped into the
next command.
If the previous command is missing (ie if ohk's standard input is the
keyboard), you will be asked to provide a command before the interactive
session starts:
➜ ohk | xargs docker stop
Enter command:
If the next command is missing (ie if ohk's standard output is the terminal
screen), you will be asked to provide one after you make your selection.
You can even use pipes in the output command and even re-invoke ohk:
➜ docker ps -a | ohk
Tips:
- use 'cat' (or leave empty) to print to terminal
- use 'xargs' to pass output as argument
- use '{}' placeholder to pass output as argument
- use 'ohk' to re-run ohk on the results
- append ' | ohk' to run ohk on the command's output
Pipe output to: sort | uniq | ohk
Note: You should not use ohk twice in the chain of processes because they
will launch in parallel and both try to take over the screen and keyboard
Keyboard shortcuts
| Esc | Quit ohk |
| Enter | Finalize selection |
| Alt-E | Change search mode |
| Alt-I | Change case sensitivity |
| ←↓↑→ / Alt-hjkl / (shift) tab | Focus rows/columns |
| Space | Select row/column |
| Alt-123456789 | Select numbered column |
| Left click | Select column |
| Alt-A/C | Select all/none rows/columns |
| Alt-R | Rerun ohk with currently selected output |
Command line options
usage: ohk [-h] [-f] [-r] [-i]
optional arguments:
-h, --help show this help message and exit
-f, --fuzzy
-r, --regex
-i, --case-insensitive
TODOs
- Use Ctrl- shortcuts
- Set output as environment variable on the outer shell (will probably need the user to set an alias)
- Scroll
- Search for column title
- Decorate
- Organize code better
Release files for ohk 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ohk-0.0.1.tar.gz | 21.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ohk-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.1 kB
Release files / ohk-0.0.1.tar.gz
| Download URL | ohk-0.0.1.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39cd0322cf25ace6ebad0284c14ae43b4b64b5476188f97770aa075085ad9eea
|
|
BLAKE2b-256 checksum How to use checksums |
8ae50a8e30365d2e2f12c04f70fcead75c179c905c9d77bf55f99302af26a78d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / ohk-0.0.1-py3-none-any.whl
| Download URL | ohk-0.0.1-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc796d862b607f96633212d99e6e6c9e431a37ebc8cbc069bbef45fd9eef637d
|
|
BLAKE2b-256 checksum How to use checksums |
2f9bcbb47ab714cb9e972a9f8c97c3966adaad1fd2a24b1279b79c5e43a43998
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|