1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-14 22:33:52 -05:00

Use compsys completion system for zsh (#1569)

The new `_rbenv` script will be autoloaded by zsh as long as it's found in $FPATH.
It should be the package manager's responsibility to symlink or move this file
into an appropriate location.

Co-authored-by: Mislav Marohnić <git@mislav.net>
This commit is contained in:
Farid NL
2024-05-03 08:57:16 -06:00
committed by GitHub
parent ac020225c2
commit a3b98a4223
4 changed files with 53 additions and 21 deletions

View File

@@ -151,6 +151,27 @@ print_usage() {
fi
}
if [ "$1" = "--complete-commands" ]; then
command_prefix="${2:-}"
seen=()
IFS=: read -d '' -r -a paths <<<"$PATH" || true
shopt -s nullglob
for path in "${paths[@]}"; do
for command in "${path}/rbenv-${command_prefix}"*; do
command_name="${command##*/}"
command_name="${command_name#rbenv-}"
command_name="${command_name#sh-}"
[[ " ${seen[*]} " != *" ${command_name} "* ]] || continue
seen+=("$command_name")
summary=""
eval "$(extract_initial_comment_block < "$command" | collect_documentation)"
[ -n "$summary" ] || continue
printf "%s:%s\n" "$command_name" "$summary"
done
done
exit 0
fi
unset usage
if [ "$1" = "--usage" ]; then
usage="1"