Detect shell

This commit is contained in:
Ian Chen 2022-11-30 17:53:00 +08:00
parent 4971d9e35e
commit c1674cd552

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Summary: Configure the shell environment for pyenv # Summary: Configure the shell environment for pyenv
# Usage: eval "$(pyenv init [-|--path] [--no-push-path] [--no-rehash] [<shell>])" # Usage: eval "$(pyenv init [-|--path] [--no-push-path] [--detect-shell] [--no-rehash] [<shell>])"
set -e set -e
[ -n "$PYENV_DEBUG" ] && set -x [ -n "$PYENV_DEBUG" ] && set -x
@ -11,6 +11,7 @@ if [ "$1" = "--complete" ]; then
echo --path echo --path
echo --no-push-path echo --no-push-path
echo --no-rehash echo --no-rehash
echo --detect-shell
echo bash echo bash
echo fish echo fish
echo ksh echo ksh
@ -33,6 +34,11 @@ do
shift shift
fi fi
if [ "$args" = "--detect-shell" ]; then
mode="detect-shell"
shift
fi
if [ "$args" = "--no-push-path" ]; then if [ "$args" = "--no-push-path" ]; then
no_push_path=1 no_push_path=1
shift shift
@ -76,12 +82,17 @@ function main() {
print_shell_function print_shell_function
exit 0 exit 0
;; ;;
"detect-shell")
detect_profile
print_detect_shell
exit 0
;;
esac esac
# should never get here # should never get here
exit 2 exit 2
} }
function help_() { function detect_profile() {
case "$shell" in case "$shell" in
bash ) bash )
if [ -e '~/.bash_profile' ]; then if [ -e '~/.bash_profile' ]; then
@ -105,7 +116,16 @@ function help_() {
rc='your shell'\''s interactive startup file' rc='your shell'\''s interactive startup file'
;; ;;
esac esac
}
function print_detect_shell() {
echo "PYENV_SHELL_DETECT=$shell"
echo "PYENV_PROFILE_DETECT=$profile"
echo "PYENV_RC_DETECT=$rc"
}
function help_() {
detect_profile
{ {
case "$shell" in case "$shell" in
fish ) fish )