Shell completion for Yarn 4+ (Berry) - supports both Bash and Zsh.
- Command completion (
add,install,run, etc.) - Flag completion (
--help,--verbose, etc.) - Dynamic generation from
yarn help - Works with Yarn 4.x and above
# Tap the Ursine Code repository
brew tap minademian/ursine
# Install from tap
brew install yarn-shell-completion
# Install directly via Homebrew
brew install minademian/ursine/yarn-shell-completionAfter installation, ensure your shell is configured for Homebrew completions:
Bash
# Add to ~/.bash_profile or ~/.bashrc (if not already present)
if type brew &>/dev/null; then
HOMEBREW_PREFIX="$(brew --prefix)"
if [[ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]]; then
source "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
fi
fiZsh
# Add to ~/.zshrc (if not already present)
if type brew &>/dev/null; then
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
autoload -Uz compinit
compinit
fiRestart your shell or run source ~/.bashrc / source ~/.zshrc.
Bash
sudo cp completions/yarn /usr/local/etc/bash_completion.d/yarn
# Then source it in your ~/.bashrc
source /usr/local/etc/bash_completion.d/yarnZsh
mkdir -p ~/.zsh/completions
cp completions/_yarn ~/.zsh/completions/
# Add to ~/.zshrc
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit- Yarn 4.x or higher
- Bash 4.0+ or Zsh 5.0+
- For Homebrew installation: Homebrew
Zsh users: Rebuild the completion cache
rm -f ~/.zcompdump*
compinitBash users: Ensure bash-completion is installed
brew install bash-completion@2 # macOS
# or
apt-get install bash-completion # LinuxZsh
type _yarn
# Should output: _yarn is a shell functionBash
type _yarn_completion_main
# Should output: _yarn_completion_main is a functionContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Test your changes thoroughly
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE file for details.
Mina Demian - mina@minademian.com
- Built for Yarn Berry (v4+)
- Inspired by the need for better Yarn completion support