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

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


当前回答

只需输入source ~/.bash_profile。

或者,如果你喜欢节省按键,你也可以打字。~ / . bash_profile。

其他回答

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

参考“源”做什么?。

只需输入source ~/.bash_profile。

或者,如果你喜欢节省按键,你也可以打字。~ / . bash_profile。

. ~/.bash_profile

只要确保你没有任何依赖于当前状态。

我喜欢的事实是,在你刚刚编辑文件后,你所需要做的就是键入:

. !$

这将在历史记录中查找刚才编辑过的文件。看看什么是砰的美元在bash。

Use

alias reload!=". ~/.bash_profile"

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

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