A lightweight Zsh plugin that allows you to "reverse search" your aliases using fzf.
Type a command (or part of one), press the hotkey, and select the matching alias. The plugin will replace your current input with the alias name and move your cursor to the end of the line.
- Reverse Lookup: Type a command (e.g.,
git commit) and find the corresponding alias (e.g.,gc). - Fuzzy Search: Filter aliases by name or command definition.
- Smart Replacement: Replaces your current buffer with the selected alias.
- Cursor Management: Automatically jumps the cursor to the end of the line after insertion.
- Previews: Shows the full command expansion in an fzf preview window.
- Zsh
- fzf (Must be installed and in your PATH)
Add the following to your .zshrc where you load your bundles:
antigen bundle forksofpower/reverse-alias-search
# OR if loading locally:
# antigen bundle /path/to/local/reverse-alias-search
- Clone this repository into your custom plugins directory:
git clone https://github.com/forksofpower/reverse-alias-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/reverse-alias-search
- Add the plugin to the list of plugins in your
.zshrc:
plugins=(... reverse-alias-search)
zplug "forksofpower/reverse-alias-search"
- Clone the repo:
git clone https://github.com/forksofpower/reverse-alias-search ~/reverse-alias-search
- Source the script in your
.zshrc:
source ~/reverse-alias-search/reverse-alias-search.plugin.zsh
- Start typing a command in your terminal (e.g.,
ls -lah). - Press
Ctrl+o(default binding). fzfwill open, pre-filled with your query.- Select the desired alias (e.g.,
ll). - The prompt will update to
lland the cursor will move to the end.
The default keybinding is Ctrl+o. You can override this by defining ZSH_FZF_ALIAS_BIND before loading the plugin.
Example (.zshrc):
# Bind to Alt+a instead of Ctrl+o
export ZSH_FZF_ALIAS_BIND='^[a'
# Load the plugin
antigen bundle forksofpower/reverse-alias-search