๐ Fish-style auto-suggestions for Zsh with history cycling support!
โจ 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
Test the plugin without making permanent changes:
source ./zsh-autosuggestions.zshThis will load the plugin for your current session only. Try typing some commands and you should see gray suggestions appear!
git clone https://github.com/jumbojett/zsh-autosuggestions-plugin.git ~/.zsh/zsh-autosuggestionsThen add to your ~/.zshrc:
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zshThen reload your shell:
source ~/.zshrc# Download the plugin
curl -o ~/.zsh/zsh-autosuggestions.zsh https://github.com/jumbojett/zsh-autosuggestions-plugin/main/zsh-autosuggestions.zsh
# Add to your ~/.zshrc
echo 'source ~/.zsh/zsh-autosuggestions.zsh' >> ~/.zshrc
# Reload shell
source ~/.zshrcFor 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- 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
- โ (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)
- โ (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)
-
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โ
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 functionTry 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
- Zsh: 5.0 or higher
- macOS: โ Fully tested
- Linux: โ Should work
- Windows (WSL): โ Should work
Works with:
- Oh My Zsh
- Prezto
- Plain zsh
-
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
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 lastThe 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)
Remove the source line from your ~/.zshrc:
# Comment out or delete this line:
# source ~/.zsh/plugins/zsh-autosuggestions.zshThen reload:
source ~/.zshrcThis 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
- 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! ๐โก๏ธ๐ง
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
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by Fish shell's auto-suggestions
- Thanks to the zsh-autosuggestions project for inspiration
- zsh-users/zsh-autosuggestions - Another excellent zsh auto-suggestions plugin
- Fish shell - The original inspiration
Made with โค๏ธ for the zsh community