4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-11 10:34:29 +08:00
nerfstudio/scripts/completions/setup.zsh
Brent Yi 86a805c88c
Experimental autocompletion setup scripts (#378)
* Working completion scripts

* generate.py => install.py

* Uninstall for completions, docs/README updates

* Tune emojis, improve concurrency for completion install

* wip

* Cleanup

* Permissions, shebang checks
2022-09-13 12:44:27 -07:00

30 lines
879 B
Bash

# Nerfactory completions for zsh.
#
# This should generally be installed automatically by `configure.py`.
completions_dir="${0:a:h}"/zsh
if [ ! -d "${completions_dir}" ]; then
echo "$0: Completions are missing!"
echo "Please generate them with nerfactory/scripts/completions/generate.py!"
return 1
fi
# Manually load and define each completion.
#
# Adding the completions directory to our fpath and re-initializing would work
# as well:
# fpath+=${completions_dir}
# autoload -Uz compinit; compinit
# But would be several orders of magnitude slower.
for completion_path in ${completions_dir}/*
do
# /some/path/to/_our_completion_py => _our_completion_py
completion_name=${completion_path##*/}
# _our_completion_py => our_completion.py
script_name="${completion_name:1:-3}.py"
autoload -Uz $completion_path
compdef $completion_name $script_name
done