macOS 升级bash

1. 首先查看电脑上安装的bash 版本。

bash --version

显示。

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18) Copyright (C) 2007 Free Software Foundation, Inc.

2. homebrew安装新版本。

brew install bash

3.查看已安装版本。

which -a bash

结果:

/usr/local/bin/bash

/bin/bash

第一个为新安装的版本,第二个为Mac自带版本, 可以用以下命令验证。

/usr/local/bin/bash --version

Copyright (C) 2020 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.

p188:MuAlloy haslab$ 

/bin/bash --version

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)

Copyright (C) 2007 Free Software Foundation, Inc.

4. 设置默认的bash版本。

sudo vim /etc/shells

把 /usr/local/bin/bash 添加到最后一行:

再执行把bash切到最新版本: 

chsh -s /usr/local/bin/bash

5. 查看(新版本 bash 应该已经生效了):

/bin/bash --version

6. 切换shell:

切换最新bash:chsh -s /usr/local/bin/bash
切换老版本bash:chsh -s /bin/bash

7. shell配置:

bash读取的配置文件:~/.bash_profile文件。

猜你喜欢

转载自blog.csdn.net/kaixinjiaoluo/article/details/120753099
今日推荐