completely icon indicating copy to clipboard operation
completely copied to clipboard

Should we add `completely install` command to install completions?

Open DannyBen opened this issue 3 years ago • 0 comments

We can port this logic from bash:

# Figure out if we need sudo or not
sudo=''
if [[ $EUID -ne 0 ]]; then
  sudo='sudo'
fi

# Install completions
if [[ -d "/usr/share/bash-completion/completions" ]]; then
  compdir="/usr/share/bash-completion/completions"
elif [[ -d "/usr/local/etc/bash_completion.d" ]]; then
  compdir="/usr/local/etc/bash_completion.d"
else
  compdir=''
fi

if [[ -n $compdir ]]; then
  echo "=== Installing autocompletions to $compdir"
  echo "eval \"\$(rush completions)\"" | $sudo tee "${compdir}/rush" > /dev/null
else
  echo "=== Completion script was not installed"
  echo "    To install it manually add this to your startup script:"
  echo "    eval \"\$(rush completions)\""
fi

DannyBen avatar May 19 '22 21:05 DannyBen