# 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.

Stars: 7.9k · Language: Go · License: MIT · Categories: Search

- Repository: https://github.com/peco/peco
- Page: https://www.trmn.sh/tools/peco

## Install

- Homebrew: `brew install peco`

## Overview

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

```bash
# via Homebrew
brew install peco
```

![peco filtering ps -ef output with the query root](https://media.trmn.sh/cached/5e130ba907cae871a009363db74332cba38c1fc370127360699f3695d74051fa.gif)

![peco used with ghq to change into a repository directory](https://media.trmn.sh/cached/61ffc582e4221282447f9330ca461e21d95953ac695851b579f563192bd8a0d1.gif)

![peco with the multi-term query root app](https://media.trmn.sh/cached/67f3c704c0c3ea70b7b3ab443e8cd56aaa330a3b4ce82d6955be8dfba08de87a.gif)

## Alternatives

- [fzf](https://www.trmn.sh/tools/fzf.md): Command-line fuzzy finder for filtering lists of files, processes, git commits, and other data with fuzzy matching. (Go, 83.8k stars)
- [skim](https://www.trmn.sh/tools/skim.md): Fuzzy finder written in Rust with interactive search capabilities and shell integration (Rust, 7.0k stars)
- [television](https://www.trmn.sh/tools/television.md): Fuzzy finder for the terminal that searches files, text, git repositories, and custom data sources in real-time (Rust, 6.4k stars)
- [rga](https://www.trmn.sh/tools/rga.md): Line-oriented search tool that extends ripgrep to search inside PDFs, archives, documents, and multimedia files (Rust, 9.9k stars)
- [howdoi](https://www.trmn.sh/tools/howdoi.md): Command-line tool that provides instant coding answers by querying Stack Overflow without opening a browser. (Python, 10.8k stars)

---

Canonical: https://www.trmn.sh/tools/peco
