I have used Bash in my career for many years and it is so convenient for data analysis.
In MacOS, however, the default shell is zsh
. To make use of bash
in MacOS,
one need the following steps:
Install the latest version of bash
One can use brew
(the MacOS package manager) to install the latest bash.
This will install bash to /usr/local/bin/bash
.
|
|
Change the default shell to /usr/local/bin/bash
To change the default shell in MacOS, one need run the following command:
|
|
Now exit the terminal and reopen one, the default shell should be the new bash.
Setup .bashrc
Since the MacOS terminal uses login based shell, it won’t
read the file .bashrc
(in contrast to *nix systems).
Also, the bash shell reads the config file firstly found in the following order (the rest are ignored:
|
|
So one need to include the following section in the config file to
trigger .bashrc
.
|
|
Install coretutils package
coreutils contains the main programs
of GNU operating systems, including dircolors
. Therefore, to use the tools,
one can install it with brew
|
|
This will install the utilities to a specific folder. To run these commands without
the folder prefix, one need to add this folder to $PATH
.
For dircolors
, one also need to change the path in .bashrc
to take effect.
Happy programming 😄!!!
References
- Explanation of zsh/bash startup files: https://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/
Last modified on 2023-05-22