https://github.com/cohml/zsh-abbr-preview
zsh-abbr plugin extension that displays abbreviation expansion previews as you type.
https://github.com/cohml/zsh-abbr-preview
Last synced: 6 months ago
JSON representation
zsh-abbr plugin extension that displays abbreviation expansion previews as you type.
- Host: GitHub
- URL: https://github.com/cohml/zsh-abbr-preview
- Owner: cohml
- License: mit
- Created: 2025-12-19T11:09:05.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-12-19T11:14:53.000Z (6 months ago)
- Last Synced: 2025-12-22T04:11:46.671Z (6 months ago)
- Language: Shell
- Size: 1.95 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zsh-plugins - abbr-preview - Previews [abbr](https://github.com/olets/zsh-abbr) abbreviations as you type. (Plugins / ZSH on Windows)
- fucking-awesome-zsh-plugins - abbr-preview - Previews <b><code> 717⭐</code></b> <b><code> 25🍴</code></b> [abbr](https://github.com/olets/zsh-abbr)) abbreviations as you type. (Plugins / ZSH on Windows)
README
# zsh-abbr-preview
Preview [`zsh-abbr`](https://github.com/olets/zsh-abbr) abbreviation expansions as you type.
## Demo
```
$ abbr g=git
Added the regular user abbreviation `g`
$ g| # "|" represents your cursor
→ git
```
Type an abbreviation and a preview of what it expands to will be displayed.
## Installation
Source `zsh-abbr-preview` in your `.zshrc` (either before or after sourcing `zsh-abbr`):
```zsh
source /path/to/zsh-abbr-preview/zsh-abbr-preview.plugin.zsh
```
Or use your plugin manager:
```zsh
# zinit
zinit light olets/zsh-abbr
zinit light cohml/zsh-abbr-preview
# oh-my-zsh
plugins=(... zsh-abbr zsh-abbr-preview)
```
## Configuration
Customize the preview prefix by setting this variable before sourcing the plugin:
```zsh
ZSH_ABBR_PREVIEW_PREFIX="..." # default: "→ "
```
## Requirements
- `zsh-abbr`
- Zsh 5.0+
## How It Works
`zsh-abbr-preview` hooks into `zle-line-pre-redraw` to check if your current input matches an abbreviation. It uses `zsh-abbr`'s own expansion functions (`_abbr_regular_expansion` and `_abbr_global_expansion`) to ensure the preview logic stays in sync with actual abbreviation behavior.
The preview should respects all `zsh-abbr` configurations, including:
- `ABBR_REGULAR_ABBREVIATION_GLOB_PREFIXES` - glob patterns for valid prefixes (e.g., "`*; `")
- `ABBR_REGULAR_ABBREVIATION_SCALAR_PREFIXES` - literal prefixes (e.g., "`sudo `")
- `ABBR_SPLIT_FN` - custom word splitting function
When an abbreviation is detected, its expansion is displayed below your prompt using `zle -M`. Multi-word abbreviations (e.g., `git s` → `git status`) are fully supported.
## License
MIT