#!/usr/bin/env bash
set -e
[ -n "$PYENV_DEBUG" ] && set -x

# Provide pyenv completions
if [ "$1" = "--complete" ]; then
  exec pyenv-rehash --complete
fi

shell="$(basename "${PYENV_SHELL:-$SHELL}")"

# When pyenv shell integration is enabled, delegate to pyenv-rehash,
# then tell the shell to empty its command lookup cache.
case "$shell" in
pwsh)
  echo "& (get-command pyenv -commandtype application) rehash"
  ;;
*)
  echo "command pyenv rehash"
esac

case "$shell" in
fish | pwsh )
  # no executable cache
  ;;
* )
  echo "hash -r 2>/dev/null || true"
  ;;
esac
