We will introduce how to install the Zsh plugin with a minimal configuration using Zsh. In this article, we will install it manually without using the plugin manager and organize the configuration of the required plugins.

overview#

Target plugin#

All of the following do not conflict with Starship.

  • zsh-autosuggestions: Suggest auto-completion from past history etc.

  • zsh-syntax-highlighting: Color-code the command syntax you are typing

  • zsh-completions: Enhanced to include non-official completions

Manual installation of plugins#

By writing the following code in .zshrc, you can clone only the first time and skip the second and subsequent times.

ZSH_PLUGIN_DIR="$HOME/.zsh/plugins"
mkdir -p "$ZSH_PLUGIN_DIR"

install_zsh_plugin() {
  local name=$1
  local url=$2
  local dir="$ZSH_PLUGIN_DIR/$name"
  if [ ! -d "$dir" ]; then
    echo "[INFO] Installing $name ..."
    git clone --depth=1 "$url" "$dir"
  fi
}

install_zsh_plugin "zsh-autosuggestions" "https://github.com/zsh-users/zsh-autosuggestions"
install_zsh_plugin "zsh-syntax-highlighting" "https://github.com/zsh-users/zsh-syntax-highlighting"
install_zsh_plugin "zsh-completions" "https://github.com/zsh-users/zsh-completions"

source "$ZSH_PLUGIN_DIR/zsh-autosuggestions/zsh-autosuggestions.zsh"
source "$ZSH_PLUGIN_DIR/zsh-completions/zsh-completions.plugin.zsh"
source "$ZSH_PLUGIN_DIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"

Order relationship with Starship#

If you are using Starship, you will need to initialize it at the top of your .zshrc.

eval "$(starship init zsh)"

# その後にプラグイン読み込みを行うこと
source "$ZSH_PLUGIN_DIR/zsh-autosuggestions/zsh-autosuggestions.zsh"
...

Exclude from Git management as dotfiles management#

Plugins can be re-obtained by cloning, so they should be excluded from Git management.

# Zsh プラグインは Git 管理対象外
.zsh/plugins/

summary#

Introducing a minimal plugin for zsh enriches the completion functions and makes command entry more efficient.

Article information

Post date:

2025-05-11

author:

Mr. Takagi