Getting autocomplete with zsh and justfile (homebrew)

312 Views Asked by At

I'm using ZSH, oh-my-zsh, and just. If I'm in the root of my directory that contains a justfile, type just, and then press tab, it doesn't autocomplete.

But if I exec zsh in terminal and then do just <tab>, it works correctly. How can I fix this? How can I make it so just autocompletes without needing to exec zsh?

Note: This question applies to anything installed with home brew

1

There are 1 best solutions below

0
Kyle Venn On BEST ANSWER

I found the solution in the just project README. I had searched this many times before and hadn't found the solution. The README must have been recently updated.

Add the following to your .zshrc:

# Needed for just autocomplete, but will pull in all of brew
# https://github.com/casey/just#shell-completion-scripts
# Init Homebrew, which adds environment variables
eval "$(brew shellenv)"
# Add Homebrew's site-functions to fpath
fpath=($HOMEBREW_PREFIX/share/zsh/site-functions $fpath)

# Needed for autosuggestions (does compinit)
source $ZSH/oh-my-zsh.sh

Note: This solution works generically for anything installed with home brew