zsh-abbr
zsh-abbr is the zsh manager for auto-expanding abbreviations - text that when written in a terminal is replaced with other (typically longer) text. Inspired by fish shell.
For example, abbreviate git checkout
as co
(or even c
or anything else). Type co
Space and the co
turns into git checkout
. Abbreviate git checkout main
as cm
. Type cm
Enter and the cm
turns into and runs git checkout main
. Don't want an abbreviation to expand? Use CtrlSpace instead of Space, and ;
Enter instead of Enter.
Why? Like aliases, abbreviations save keystrokes. Unlike aliases, abbreviations can leave you with a transparently understandable command history ready for using on a different computer or sharing with a colleague. And where aliases can let you forget the full command, abbreviations may help you learn the full command even as you type the shortened version.
Like zsh's alias
, zsh-abbr supports "regular" (i.e. command-position) and "global" (anywhere on the line) abbreviations. Like fish's abbr
, zsh-abbr supports interactive creation of persistent abbreviations which are immediately available in all terminal sessions. Abbreviations automatically sync to a file, ready for your dotfile management.
Run abbr help
for documentation; if the package is installed with Homebrew, man abbr
is also available.