PSReadLine-style ListView prediction for zsh. Predictions come only from commands that exited 0 — typos and failures stay in raw history but never pollute your suggestions.
Inspired by PSReadLine's ListView prediction mode for PowerShell.
- No ghost text — clean list below the prompt, not mixed into your input
- Header line — shows
<-/N>(no selection) or<K/N>(selected), with source count - Source tags — each item shows
[History]right-aligned - Success-only — only commands that exited 0 feed predictions
- Buffer updates on navigation — ↓ selects an item and puts it in your buffer, ↑ restores your typed text
zinit light testycool/zsh-predictive-listgit clone https://github.com/testycool/zsh-predictive-list ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-predictive-list
# Add to plugins=(...) in .zshrcsource /path/to/zsh-predictive-list.plugin.zsh| Key | Action |
|---|---|
| Type anything | List updates automatically |
Down |
Enter list / select next item (buffer updates to match) |
Up |
Select previous item / deselect (restores typed text) |
Right |
Accept top prediction (or selected) when cursor is at end of line |
Tab |
Accept current selection (only while navigating); otherwise normal completion |
Enter |
Execute current buffer |
Ctrl+G |
Dismiss list, restore typed text |
Alt+P |
Toggle predictions on/off |
Additional widgets (not bound by default — bind them yourself if needed):
| Widget | Action |
|---|---|
zpred-delete-entry |
Remove the selected entry from prediction history |
When no predictions match, Up/Down/Right fall back to their normal behavior.
Set these before sourcing the plugin:
# History file location (default: ~/.local/share/zsh-predictive-list/success_history)
ZPRED_HISTORY="$HOME/.zsh_success_history"
# Max visible predictions (default: 6)
ZPRED_MAX_SHOW=8
# Max entries kept in memory and on disk (default: 5000)
ZPRED_MAX_HISTORY=5000
# Match mode: "prefix" (default) or "contains" (substring matching, prefix results shown first)
ZPRED_MATCH_MODE="contains"
# Styles (zsh region_highlight format)
ZPRED_STYLE_EMPHASIS="fg=yellow" # matched prefix in unselected items
ZPRED_STYLE_SELECTED="standout" # selected item (reverse video)
ZPRED_STYLE_DIM="fg=8" # header, markers, source tagsNew installs start with an empty prediction list. Import from your existing zsh history:
zpred-import # imports from $HISTFILE (handles both plain and EXTENDED_HISTORY format)
zpred-import /path/to/file # import from a specific fileSince exit codes aren't stored in $HISTFILE, all entries are imported. The prediction list will self-correct over time as successful commands get recorded.
preexeccaptures each command before executionprecmdchecks$?— if 0, the command is appended to the success history filezle-line-pre-redrawdetects buffer changes and updates the prediction list- Matching runs against the deduplicated, most-recent-first success history (prefix or substring)
- List renders via
POSTDISPLAY+region_highlight(no ghost text) - Navigation with ↓ updates BUFFER to the selected command; ↑ at top restores typed text
- Ctrl+G dismisses the list; typing again un-dismisses it
- History file auto-truncates when it exceeds 2×
ZPRED_MAX_HISTORY
| zsh-predictive-list | zsh-autosuggestions | zsh-autocomplete | |
|---|---|---|---|
| Display | List below prompt | Inline ghost text | Completion menu |
| Source | Success history only | Full history + completion | Completion system |
| Navigation | ↑/↓ through list | → to accept | Tab cycling |
| Buffer | Updates on selection | Unchanged until accept | Unchanged until accept |
- zsh >= 5.4 (for
zle-line-pre-redraw)
- Chains with existing
zle-line-init,zle-line-pre-redraw, andzle-line-finishhooks - Conflicts with zsh-autosuggestions — both use
POSTDISPLAY. Use one or the other.
MIT