Zoltan King
Zoltan King

Reputation: 2282

How to hide terminal warning when Oh-my-ZSH plugin can't access external app

I've been using oh-my-zsh for a while and it's working great. I'd like to use the command-line fuzzy finder plugin so I enabled it in .zshrc:

plugins=(fzf)

However if "fzf" is not installed I get a warning when opening my terminal window:

[oh-my-zsh] fzf plugin: Cannot find fzf installation directory. Please add export FZF_BASE=/path/to/fzf/install/dir to your .zshrc

Is there a way to hide that warning message? When I install fzf with "sudo dnf install fzf" the warning dissapears, but maybe I want to clone my dotfiles on a different computer where it is not available and it's not that important to be there.

Upvotes: 6

Views: 4929

Answers (5)

bobaepapa
bobaepapa

Reputation: 1

When you install fzf by using brew, it needs to be set brew env.
You can solve to set PATH for fzf before the line of plugins=(fzf) in .zshrc file.

But, I recommand creating "$HOME/.zprofile" as following.

For m1 Mac.

# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/opt/homebrew/bin/brew shellenv)"

For, intel Mac

# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/usr/local/bin/brew shellenv)"

Upvotes: 0

flymg
flymg

Reputation: 627

For me, it was also very important that brew itself was in Path of ~/.zshenv like so:

export PATH=/opt/homebrew/bin:$PATH 

Installed FZF with brew on an M1 Mac.

Otherwise, the error occurs:

[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
Please add `export FZF_BASE=/path/to/fzf/install/dir` to your .zshrc

Upvotes: 0

Micheal Bee
Micheal Bee

Reputation: 638

You need to have fzf installed to use this plugin; otherwise remove it. It won't do anything without first installing fzf. Sudo apt install fzf

Upvotes: 1

xxyxxyxyx1
xxyxxyxyx1

Reputation: 89

You can put the plugins= line inside an if statement that checks for the presence of fzf in your path. For example:

if [[ -n $(command -v fzf) ]] ; then
    echo "fzf found, loading oh-my-zsh fzf plugin"
    plugins=(vi-mode fzf)
else
    echo "no fzf was found in the path"
    plugins=(vi-mode)
fi

command -v is similar to which, but is superior for this context as explained in this answer. The -n makes the [[ ]] evaluate as true whenever the $() produces a non-empty output.

Upvotes: 0

dadanier
dadanier

Reputation: 161

you should first install fzf, in Mac and i use the following command to install brew install fzf

Upvotes: 3

Related Questions