GNU Readline-style reverse history search for pi. Press Ctrl+R in the editor to revisit prompts and bash commands from the current branch history without leaving the editor.
pi install ./pi install git:github.com/mrshu/pi-readline-search- Press Ctrl+R in the editor to open reverse search.
- Type to filter the branch-local history index.
- Press Ctrl+R or ↑ to move to older matches.
- Press Ctrl+S or ↓ to move to newer matches.
- Press Enter to insert the selected match, or Esc/Ctrl+G to cancel.
The index includes user prompts and bashExecution commands. Commands keep their pi prefixes as !command or !!command depending on context inclusion.
Configure extension shortcuts in Pi's keybindings file (~/.pi/agent/keybindings.json, or PI_CODING_AGENT_DIR/keybindings.json when set):
{
"readline-search.reverse-search": "ctrl+r",
"readline-search.reverse-search-older": ["ctrl+r", "up"],
"readline-search.reverse-search-newer": ["ctrl+s", "down"],
"readline-search.reverse-search-accept": "enter",
"readline-search.reverse-search-cancel": ["escape", "ctrl+g"],
"readline-search.history-search-backward": "up",
"readline-search.history-search-forward": "down"
}Each value may be a string or an array of strings. Unset keys use the defaults shown above.
The up/down defaults are context-specific: in the main editor they trigger prefix-history search, while inside the reverse-search UI they navigate matches.
Pi may also use ctrl+r for renaming sessions. If that conflicts in your setup, either move Pi's rename-session shortcut to another key, such as ctrl+shift+r:
{
"app.session.rename": "ctrl+shift+r"
}Or keep Pi's rename-session shortcut on ctrl+r and rebind this extension's reverse search instead:
{
"readline-search.reverse-search": "ctrl+shift+r",
"readline-search.reverse-search-older": ["ctrl+shift+r", "up"]
}With this config, pressing ↑/↓ in Pi replaces the editor contents with the previous/next prompt or ! bash command that starts with the current editor text.
| Key | Action |
|---|---|
readline-search.reverse-search |
Open search |
readline-search.reverse-search-older |
Cycle older matches inside search |
readline-search.reverse-search-newer |
Cycle newer matches inside search |
readline-search.reverse-search-accept |
Accept selected match into the editor |
readline-search.reverse-search-cancel |
Cancel reverse search |
readline-search.history-search-backward / readline-search.history-search-forward |
Optional prefix-history search in the main editor |
- If pi shows "No prompt history yet for reverse search.", there are no indexed prompts or
bashExecutionentries in this branch yet. - Fresh branches can show no results until you create some prompt or command history.
- If
Ctrl+Ris intercepted by another tool, rebindreadline-search.reverse-searchin Pi's keybindings file.
- Works with pi extension loading via
pi.extensions: ["./extensions"]and the entry fileextensions/readline-search.ts. - No extra OS-specific setup is required beyond a working pi environment.
pi -e ./extensions/readline-search.tsSee CHANGELOG.md for release history.
This repo is a pi package via package.json:
pi.extensions: ["./extensions"]- Extension entry:
extensions/readline-search.ts