DEV Community

johanputra
johanputra

Posted on

Install zsh with autosuggestion in amazon linux

To install zsh and Oh My Zsh with the suggestion plugin on Amazon Linux, follow these steps:

#!/bin/sh # Install zsh sudo yum install git zsh -y sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" # Install zsh-syntax-highlighting plugin git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting # Install zsh-autosuggestions plugin git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions echo "plugins=(zsh-syntax-highlighting zsh-autosuggestions)" >> ~/.zshrc echo "source ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ~/.zshrc echo "ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=blue'" >> ~/.zshrc echo "ZSH_AUTOSUGGEST_USE_ASYNC=true" >> ~/.zshrc source ~/.zshrc echo "Installation of zsh and Oh My Zsh with suggestion plugin complete!" 
Enter fullscreen mode Exit fullscreen mode
  • Install zsh:
sudo yum install zsh 
Enter fullscreen mode Exit fullscreen mode
  • Install Oh My Zsh:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" 
Enter fullscreen mode Exit fullscreen mode
  • Install the zsh-syntax-highlighting plugin (required for the suggestion plugin):
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting 
Enter fullscreen mode Exit fullscreen mode
  • Install the zsh-autosuggestions plugin (suggestion plugin):
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions 
Enter fullscreen mode Exit fullscreen mode
  • Add the plugins to your Oh My Zsh configuration file:
echo "plugins=(zsh-syntax-highlighting zsh-autosuggestions)" >> ~/.zshrc 
Enter fullscreen mode Exit fullscreen mode
  • Restart your terminal or run source ~/.zshrc to apply the changes.

Note: If you want to use the suggestion plugin with the default Oh My Zsh theme, you may need to add the following line to your ~/.zshrc file:

source ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh 
Enter fullscreen mode Exit fullscreen mode

Also, you can configure the suggestion plugin by adding the following lines to your ~/.zshrc file:

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=blue' ZSH_AUTOSUGGEST_USE_ASYNC=true 
Enter fullscreen mode Exit fullscreen mode

This will highlight the suggestions in blue and use asynchronous suggestions.

After installing and configuring the suggestion plugin, you can use it by typing a command and then pressing the key (or Tab key) to accept the suggestion.

Top comments (0)