thatsalva
thatsalva

Reputation: 43

Why are only certain plugins in zsh working while others aren't?

This is my full .zshrc:

export ZSH="/Users/butters/.oh-my-zsh"

source $ZSH/oh-my-zsh.sh
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh

plugins=(
    git
    bundler
    dotenv
    osx
    zake
    zsh-syntax-highlighting
    zsh-autosuggestions

)

It seems that only when source $ZSH/oh-my-zsh.sh is placed above the rest, my custom plugins work but all the other plugins such as osx stop working. When I placed it below the rest, osx works but zsh-syntax-highlighting and zsh-autosuggestions stop working.

Upvotes: 4

Views: 3574

Answers (1)

Marlon Richert
Marlon Richert

Reputation: 7040

There are three problems in your setup:

  • plugins is an array used by $ZSH/oh-my-zsh.sh. You need to initialize the former before calling the latter. Just initializing plugins by itself doesn't do anything special in plain Zsh (apart from creating a plain old array).
  • zsh-syntax-highlighting and zsh-autosuggestions mention explicitly in their documentation that they should be sourced after any other plugins.
  • If you're going to manually source a plugin, then you do not need to add it to Oh-My-Zsh's plugins array.

So, therefore, for your setup, this is the correct way to do things:

ZSH=~/.oh-my-zsh
plugins=(
    git
    bundler
    dotenv
    osx
    zake
)
source $ZSH/oh-my-zsh.sh

source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Upvotes: 7

Related Questions