ZSH Auto-Suggestions
October 17, 2025 Β· View on GitHub
π Fish-style auto-suggestions for Zsh with history cycling support!
Features
β¨ Real-time suggestions - See command suggestions in gray text as you type
π Cycle through options - Use β/β arrows to browse through matching commands
β‘ Fast and native - Built with pure zsh, no external dependencies
π¨ Customizable - Easy to configure colors and behavior
π Smart history search - Searches through your entire command history
Quick Start
Option 1: Load Temporarily (Test First)
Test the plugin without making permanent changes:
source ./zsh-autosuggestions.zsh
This will load the plugin for your current session only. Try typing some commands and you should see gray suggestions appear!
Installation
Option 1: Clone the repository
git clone https://github.com/jumbojett/zsh-autosuggestions-plugin.git ~/.zsh/zsh-autosuggestions
Then add to your ~/.zshrc:
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
Then reload your shell:
source ~/.zshrc
Option 2: Direct download
# Download the plugin
curl -o ~/.zsh/zsh-autosuggestions.zsh https://raw.githubusercontent.com/jumbojett/zsh-autosuggestions-plugin/main/zsh-autosuggestions.zsh
# Add to your ~/.zshrc
echo 'source ~/.zsh/zsh-autosuggestions.zsh' >> ~/.zshrc
# Reload shell
source ~/.zshrc
Option 3: Install to Standard Plugin Location
For a cleaner setup, move the plugin to your zsh plugins directory:
# Create plugins directory if it doesn't exist
mkdir -p ~/.zsh/plugins
# Copy the plugin
cp ./zsh-autosuggestions.zsh ~/.zsh/plugins/
# Add to ~/.zshrc
echo 'source ~/.zsh/plugins/zsh-autosuggestions.zsh' >> ~/.zshrc
# Reload shell
source ~/.zshrc
Usage
Auto-Suggestions
- As you type: See suggestions in gray text automatically
- From history: Suggestions come from your zsh command history
- Smart matching: Only shows commands that start with what you've typed
Accepting Suggestions
- β (Right Arrow): Accept entire suggestion when cursor is at end of line
- End Key: Accept entire suggestion
- Ctrl+β: Accept one word at a time
- Tab: Normal tab completion (unchanged)
Cycling Through Suggestions
- β (Up Arrow): When cursor is at end of line with text, cycle to older suggestions
- β (Down Arrow): Cycle to newer suggestions
- ββ with empty line: Normal history navigation (unchanged)
Usage Examples
-
Type a common command:
$ giβYou might see:
git statusin gray -
Press β to accept:
$ git statusβ -
Or press β to see other suggestions:
$ git pushβ (or git pull, git commit, etc.) -
Accept word-by-word with Ctrl+β:
$ gitβ β $ git statusβ β $ git status --shortβ
Customization
Edit the configuration section in zsh-autosuggestions.zsh:
# Change suggestion color (currently gray)
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8' # Try: fg=240, fg=244, etc.
# Maximum number of suggestions to cache
# (currently set to 10, increase for more cycling options)
# Change this number in the _zsh_autosuggest_fetch_suggestion function
Available Colors
Try different gray shades by changing fg=8:
fg=8- Default grayfg=240- Darker grayfg=244- Medium grayfg=248- Lighter grayfg=cyan,dim- Dimmed cyanfg=blue,dim- Dimmed blue
Compatibility
- Zsh: 5.0 or higher
- macOS: β Fully tested
- Linux: β Should work
- Windows (WSL): β Should work
Works with:
- Oh My Zsh
- Prezto
- Plain zsh
Troubleshooting
Suggestions not appearing?
-
Check your history exists:
history | head -
Try typing a command you've used before
-
Look for the success message when loading:
β ZSH Auto-Suggestions loaded
Conflicts with other plugins?
Load this plugin after other plugins in your ~/.zshrc:
source ~/.oh-my-zsh/oh-my-zsh.sh # Load framework first
# ... other plugins ...
source ~/.zsh/zsh-autosuggestions.zsh # Load this last
Arrow keys not working?
The plugin preserves normal arrow key behavior:
- ββ with empty line = normal history navigation
- ββ with text at end = cycle through suggestions
- ββ = normal cursor movement + accept suggestion when at end (new)
Uninstalling
Remove the source line from your ~/.zshrc:
# Comment out or delete this line:
# source ~/.zsh/plugins/zsh-autosuggestions.zsh
Then reload:
source ~/.zshrc
How It Works
This plugin integrates with zsh's line editor (ZLE) by:
- Wrapping widgets - Intercepts keyboard input via ZLE widgets
- Searching history - Uses zsh's built-in
$historyarray - Display via POSTDISPLAY - Shows suggestions using zsh's
POSTDISPLAYvariable - Highlighting - Applies gray color using
region_highlight - Hook system - Uses
line-pre-redrawto maintain display across redraws
Next Steps
- Test it:
source zsh-autosuggestions.zshin your terminal - Try it out: Type some commands and experiment with the keys
- Customize: Adjust the color and behavior to your liking
- Make it permanent: Add to your
~/.zshrcwhen satisfied
Enjoy your fish-style auto-suggestions in zsh! πβ‘οΈπ§
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Inspired by Fish shell's auto-suggestions
- Thanks to the zsh-autosuggestions project for inspiration
Related Projects
- zsh-users/zsh-autosuggestions - Another excellent zsh auto-suggestions plugin
- Fish shell - The original inspiration
Made with β€οΈ for the zsh community