如何从命令行重新加载文件.bash_profile ?
通过退出并重新登录,我可以让shell识别对.bash_profile的更改,但我希望能够按需执行。
如何从命令行重新加载文件.bash_profile ?
通过退出并重新登录,我可以让shell识别对.bash_profile的更改,但我希望能够按需执行。
当前回答
Use
alias reload!=". ~/.bash_profile"
或者如果想通过函数添加日志:
function reload! () {
echo "Reloading bash profile...!"
source ~/.bash_profile
echo "Reloaded!!!"
}
其他回答
简单地重新获取文件不会“重新加载”,即先卸载某些内容,然后再加载。如果这是你想要的,你可以这样做:
hash -r && _SHOW_MESSAGES=1 exec -a -bash bash
只需输入source ~/.bash_profile。
或者,如果你喜欢节省按键,你也可以打字。~ / . bash_profile。
. ~/.bash_profile
只要确保你没有任何依赖于当前状态。
添加别名bashs="source ~/ "。bash_profile”到Bash文件中。
所以下次你可以调用bash。
您还可以使用此命令重新加载~/。该用户的Bash_profile。一定要用破折号。
su - username