peco

Interactive line filter written in Go that reads stdin, filters incrementally as you type, and prints selected lines to stdout. Single binary, no dependencies.

install· Homebrew

peco is an interactive filtering tool for the terminal. It reads lines from stdin or a file, shows them in a TUI, and narrows the list as you type a query. When you press Enter, the selected line is printed to stdout so it can be piped to other commands, for example ps -ef | peco or cd $(ghq list --full-path | peco --query peco). It is a Go rewrite of the Python tool percol, distributed as a single binary.

Queries with multiple terms are AND queries. A term prefixed with - excludes lines (SSO -tests -javadoc), and the prefix can be changed or disabled with --negation-prefix. Filters include IgnoreCase (the default), CaseSensitive, SmartCase, Regexp, IRegexp and Fuzzy, and you can toggle between them or restrict the rotation with --filter or the Filters config section. You can select multiple lines or a range of lines, and the peco.FreezeResults and peco.UnfreezeResults actions let you filter in stages on top of a frozen result set.

Other documented features include ANSI color passthrough (--color=auto by default, --color=none to disable). Matching runs on the stripped text, and the output keeps the original escape codes. peco.ZoomIn and peco.ZoomOut show 3 lines of context around matches, similar to grep -C. peco.ScrollLeft and peco.ScrollRight scroll long lines horizontally. Several of these actions have no default key binding and must be bound in the JSON config file's Keymap section. The config file also controls styles and options such as MaxScanBufferSize and FuzzyLongestSort.

It suits developers and sysadmins who filter logs, process lists, file lists, or git repository lists from the shell, and who combine it with zsh functions or tools like ghq.

Installation

# via Homebrew
brew install peco

peco filtering ps -ef output with the query root

peco used with ghq to change into a repository directory

peco with the multi-term query root app

Alternatives & related tools

add a badge to your README

Maintain peco? Show that it's featured on trmn. The badge links back to this page.

Featured on trmn
Markdown
[![Featured on trmn](https://www.trmn.sh/badge/peco.svg)](https://www.trmn.sh/tools/peco?utm_source=badge)
HTML
<a href="https://www.trmn.sh/tools/peco?utm_source=badge"><img src="https://www.trmn.sh/badge/peco.svg" alt="Featured on trmn" height="20"></a>