diff --git a/README.md b/README.md index 47117fcc..e480589a 100644 --- a/README.md +++ b/README.md @@ -528,7 +528,7 @@ opposed to this idea. Here's what `eval "$(pyenv init -)"` actually does: for some reason you need `pyenv` to be a real script rather than a shell function, you can safely skip it. -`eval "$(pyenv init --path)"` only does item 1. +`eval "$(pyenv init --path)"` only does items 1 and 3. To see exactly what happens under the hood for yourself, run `pyenv init -` or `pyenv init --path`. diff --git a/libexec/pyenv-init b/libexec/pyenv-init index 160931fd..6d6cbf9a 100755 --- a/libexec/pyenv-init +++ b/libexec/pyenv-init @@ -57,6 +57,7 @@ function main() { ;; "path") print_path + print_rehash exit 0 ;; "print") @@ -64,6 +65,7 @@ function main() { print_path print_env print_completion + print_rehash print_shell_function exit 0 ;; @@ -168,7 +170,9 @@ function print_completion() { if [ -r "$completion" ]; then echo "source '$completion'" fi +} +function print_rehash() { if [ -z "$no_rehash" ]; then echo 'command pyenv rehash 2>/dev/null' fi diff --git a/test/init.bats b/test/init.bats index cfae0f4f..154d340b 100755 --- a/test/init.bats +++ b/test/init.bats @@ -17,6 +17,13 @@ load test_helper assert_line "command pyenv rehash 2>/dev/null" } +@test "auto rehash for --path" { + run pyenv-init --path + assert_success + assert_line "command pyenv rehash 2>/dev/null" +} + + @test "setup shell completions" { root="$(cd $BATS_TEST_DIRNAME/.. && pwd)" run pyenv-init - bash