loading...

A Guide for Upgrading macOS to Catalina and Migrating the Default Shell from Bash to Zsh

saltyshiomix profile image Shiono Yoshihide ・2 min read

Index

  • From Bash to Zsh
  • Configure Zsh
    • Minimal Configuration
    • Enable Git Completion
    • Define Aliases
  • Prettify the Console with Starship πŸš€

From Bash to Zsh

After upgrading macOS to Catalina (lol), the command below changes the default shell to zsh:

$ chsh -s /bin/zsh

That's it!

Configure Zsh

Minimal Configuration

To configure zsh, just populate ~/.zshrc like this:

# enable the default zsh completions!
autoload -Uz compinit && compinit

Enable Git Completion

To enable git completion, try commands below:

# make the `.zsh` directory
$ mkdir -p ~/.zsh
$ cd ~/.zsh

# download the scripts for completion
$ curl -o git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
$ curl -o _git https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.zsh

After that, we can load the scripts in the ~/.zshrc:

zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash
fpath=(~/.zsh $fpath)

Finally, remove the cache:

$ rm ~/.zcompdump

Define Aliases

My favorite and minimal aliases are:

alias ..='cd ..'
alias ...='cd ../..'
alias ls='ls -GwF'
alias ll='ls -alh'

Yes ll is not defined when using zsh.

And if we use VSCode, we can edit ~/.zshrc by running the command zshrc:

alias zshrc='code ~/.zshrc'

In the same way, to edit ~/.gitconfig by the command gitconfig, add the line below in the ~/.zshrc:

alias gitconfig='code ~/.gitconfig'

Prettify the Console with Starship πŸš€

Do you know starship?

TLDR, see my pretty console :)

my pretty console image

I love this console! lol

Installation

$ brew install starship

And add the init script to the end of ~/.zshrc:

eval "$(starship init zsh)"

Configuration

For full information, please see the documentation.

My minimal configuration as a TypeScript developer, a cat lover and a basketball enthusiast is:

# in `~/.config/starship.toml`

[character]
symbol = "πŸˆπŸ’•"

[directory]
fish_style_pwd_dir_length = 10

[git_branch]
symbol = "πŸ€ "

[nodejs]
symbol = "⚑ "

[package]
symbol = "πŸŽ‰ "
symbol why or what
πŸˆπŸ’• just so cute - nyaaan in Japanese / meow in English
πŸ€ master git branch
⚑ v12.11.1 nodejs version
πŸŽ‰ v6.6.0 package version

Conclusion

No console, no developers :)

Discussion

pic
Editor guide
Collapse
davidxswang profile image
Davidxswang

Thank you for this post! I met the problem a few days ago that I cannot use auto completion when I was using git, but it worked before. I searched a lot of places but didn't solve this problem perfectly, either prompting warning for me or prompting a lot of errors. Your post just solved it! Thank you!

Collapse
stephanie profile image
Stephanie Handsteiner

zsh + ohmyzsh + powerlevel10k >

Collapse
ajonp profile image
Alex Patterson

I too am a cat lover, basketball enthusiast, and struggling TypeScript developer πŸ™€.

Great tutorial!

Collapse
pedroapfilho profile image
Pedro Filho

What should I do if I already had zsh+ohmyzsh installed?

Collapse
saltyshiomix profile image
Shiono Yoshihide Author

You can see the current default shell by running the command below:

$ echo ${SHELL}

If the result is /bin/zsh, this is the default macOS shell.

So you need to change it:

$ chsh -s /path/to/your/custom/zsh

And check your default shell has changed by running echo ${SHELL} :)

Collapse
codenutt profile image
Jared

How lucky for us who switched to Zsh many moons ago lol

Collapse
walkingriver profile image
Michael D. Callaghan

Very nice. Thank you.

Collapse
brando90 profile image
brando90

does one not need (the old) .bashrc anymore when using zsh? Everything goes to .zhrc right?

Collapse
saltyshiomix profile image
Shiono Yoshihide Author

If you are using MacOS Catalina from the first, everything goes to zsh. Otherwise if you upgrade OS, we need change the default shell from bash to zsh :)