/root/.bashrc 做什么?

What does /root/.bashrc do?

echo 'export PYENV_ROOT="/root/.pyenv"' >> /root/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> /root/.bashrc
echo 'eval "$(pyenv init -)"' >> /root/.bashrc
. /root/.bashrc

有人可以帮我理解这个脚本的作用吗?或者可能会向我指出具有更好解释的文档。

非常感谢!

来自 bash 的手册页 (man bash):

When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc [...]

推荐阅读:6.2 Bash Startup Files from Bash Reference Manual

您实际上可以在 基本 GitHub 结帐 :

部分下找到解释

https://github.com/yyuu/pyenv

转自网页:

Define environment variable PYENV_ROOT to point to the path where pyenv repo is cloned and add $PYENV_ROOT/bin to your $PATH for access to the pyenv command-line utility.

$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile

Zsh note: Modify your ~/.zshenv file instead of ~/.bash_profile. Ubuntu note: Modify your ~/.bashrc file instead of ~/.bash_profile.

Add pyenv init to your shell to enable shims and autocompletion. Please make sure eval "$(pyenv init -)" is placed toward the end of the shell configuration file since it manipulates PATH during the initialization.

$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

如果您想了解更多信息,您可能应该阅读本页的 Invoked as an 部分 交互式非登录 shell:

https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html