如何从命令行重新加载文件.bash_profile ?

通过退出并重新登录,我可以让shell识别对.bash_profile的更改,但我希望能够按需执行。


当前回答

添加别名bashs="source ~/ "。bash_profile”到Bash文件中。

所以下次你可以调用bash。

其他回答

添加别名bashs="source ~/ "。bash_profile”到Bash文件中。

所以下次你可以调用bash。

保存.bash_profile文件 输入cd进入用户的主目录 使用.bash_profile重新加载配置文件

如果.bash_profile文件不存在,可以尝试执行以下命令:

. ~/.bashrc

or

source ~/.bashrc

而不是。bash_profile。

您可以找到关于bashrc的更多信息。

你只需要打字。~ / . bash_profile。

参考“源”做什么?。

Use

alias reload!=". ~/.bash_profile"

或者如果想通过函数添加日志:

function reload! () {
    echo "Reloading bash profile...!"
    source ~/.bash_profile
    echo "Reloaded!!!"
}