I was just following the install instructions for zsh-autosuggestions and I don't understand what part of the following command is doing:

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
  • What does the ${ZSH_CUSTOM:- ...} do?
  • Why not just clone directly into ~/.oh-my-zsh/...?

The parameter substitution ${variable:-value} would be replaced by $variable if that variable was set and not empty, otherwise it's replaced by value. This is a standard parameter expansion.

In this case, it allows the user to set ZSH_CUSTOM to where they keep their oh-my-zsh customisation files, or to not set it and use the default location of ~/.oh-my-zsh/custom.

Not using this construct would make the life of users who have tailor made setups a bit awkward as they would have to either manually modify the command, or move the files to the correct place after installation (and possibly run the risk of having pre-existing files overwritten by git clone).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.