Skip to main content

An interactive alternative to grep and awk

Project description

ohk, an interactive replacement to tools like grep and awk

asciicast

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ohk-0.0.1.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

ohk-0.0.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file ohk-0.0.1.tar.gz.

File metadata

  • Download URL: ohk-0.0.1.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for ohk-0.0.1.tar.gz
Algorithm Hash digest
SHA256 39cd0322cf25ace6ebad0284c14ae43b4b64b5476188f97770aa075085ad9eea
MD5 8994f173a0cab9ba2badf90754f7ed94
BLAKE2b-256 8ae50a8e30365d2e2f12c04f70fcead75c179c905c9d77bf55f99302af26a78d

See more details on using hashes here.

File details

Details for the file ohk-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ohk-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for ohk-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc796d862b607f96633212d99e6e6c9e431a37ebc8cbc069bbef45fd9eef637d
MD5 047a0f2258ff7c4135a4c55bb0053477
BLAKE2b-256 2f9bcbb47ab714cb9e972a9f8c97c3966adaad1fd2a24b1279b79c5e43a43998

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page