I was quite surprised to find zsh as default shell (root still logs into sh) with Catalina. I know very little about zsh. It seems to be quite popular and the way to go. But I have too many bash scripts to maintain and I need the venerable bash as my default shell.

Temporary switch

Of course, the shebang still points to the right shell interpreter and I can run these scripts from zsh. But, time to time, I need to invoke them from a script in the command line or just source some functions. I also develop locally scripts that will be deployed on servers where zsh is not installed and I found myself using more and more often :

exec bash -l

... that at the end I decided to switch permanently.

Permanent switch

To make bash your default login shell, just open a fresh terminal and type :

chsh bash -s /bin/bash
exec bash -l

Where is my Run Commands (rc) file ?

Every time you start a bash shell as a login shell, bash runs, in this order :

/etc/profile
/etc/bashrc
~/.bash_profile
~/.bashrc # if called from the above script

If the bash is invoked from a script, or is executed without the --login or -l option, only ~/.bashrc is invoked.

I'm sharing here a subset of my files so you can easily switch back to bash

~/.bash_profile (invoked only from a login shell):
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

export EDITOR=vim
export PATH=~/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
~/.bashrc :
alias vi=vim
alias ls='ls -G'
alias ll='ls -l'
alias la='ls -la'

# iterm2 shell integration :
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

Version

The bash version shipped with Catalina is a bit outdated.

cold [ ~ ]$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Copyright (C) 2007 Free Software Foundation, Inc.

Until now, I had no issue running my old scripts. And I don't plan to upgrade the shell. Instead I think to switch smoothly to zsh and migrate the scripts.


Published

Category

Admin

Tags

Contact