8 releases (stable)

1.3.5 Apr 7, 2024
1.3.4 Jul 3, 2023
1.3.3 Nov 3, 2022
1.3.2 Jun 7, 2022
0.1.0 Apr 19, 2021

#94 in Text processing

Download history 5/week @ 2024-03-08 2/week @ 2024-03-15 6/week @ 2024-03-29 110/week @ 2024-04-05 13/week @ 2024-04-12 1/week @ 2024-05-17

375 downloads per month

MIT license

4.5MB
2.5K SLoC

Rust 2K SLoC // 0.0% comments Python 489 SLoC // 0.1% comments

igrepper - The interactive grepper

Filter and explore text with instant feedback. The regex is re-evaluated at every keypress. Also useful for quickly developing and testing regular expressions.

Installation

Either:

  1. Download binary
    To install without setting up a rust environment, grab the igrepper binary from the latest release: https://github.com/igoyak/igrepper/releases
    Then make it executable with chmod and put it in your PATH.

  2. Install using cargo
    cargo install igrepper

  3. Build and run from source code
    cargo run

Dependencies

Ubuntu: apt-get install xsel for clipboard support

Usage

Recommended .bashrc additions:

alias i='igrepper'
iman() {
  man "$1" | igrepper --context 3
}

Read input from pipe:

dmesg | i

Read input from file:

i /etc/fstab

Create a grep command using ctrl-g:

See context around matches:

Reload the file as it changes (similar to tail -f):

i -f somefile.log

Commands:

Edit the current regex by typing.

Movement:

Command Action
Up/Down/Left/Right/PageUp/PageDown Scroll
ctrl-u/ctrl-d Half-page scroll

Searching:

Command Action
ctrl-n/ctrl-j/Enter Accept current regex, start a sub-search
ctrl-p Revert sub-search
ctrl-i Toggle case sensitivity
ctrl-v Toggle inverted
ctrl-r/ctrl-t Decrease/Increase context-lines

Exporting:

Command Action
ctrl-e Copy current match to clipboard
ctrl-g Copy equivalent grep command to clipboard
F1 Pipe current match to the configured external editor
(Inside vim) F1 Pipe current buffer to igrepper (add map <F1> :silent :w !igrepper<CR>:q!<CR> to your .vimrc)

Configuration

External editor

Set the environment variable IGREPPER_EDITOR to a command and arguments, separated by whitespace, to customize which editor is used when pressing F1. The command must support reading from STDIN.

Example .bashrc configuration:

export IGREPPER_EDITOR="vim -R -" # vim in read-only mode (default)
export IGREPPER_EDITOR="code -" # vscode
export IGREPPER_EDITOR="nano -v -" # nano in read-only mode

Supported platforms

Tested on Ubuntu 20.04

Known issues

  • No unicode support
  • Broken colors when using screen/tmux and urxvt. As a workaround, you can either:
    • Run export TERM=rxvt-unicode-256color
    • Add term screen-256color to your .screenrc

Dev dependencies

Ubuntu: apt-get install libncurses-dev

Build release version

Either:

  • cargo build --release
  • rm -r dockertarget; docker build . -t igrepperbuild && docker run --name igrepperbuild igrepperbuild && docker cp igrepperbuild:/tmp/target/release dockertarget; docker rm igrepperbuild

Publish release

  • Bump version in Cargo.toml
  • Bump version in main.rs
  • cargo publish --dry-run
  • cargo publish
  • git push
  • Create release in Github from ./target/release/igrepper

Dependencies

~3–4.5MB
~70K SLoC