Max Belsky
Posted on October 1, 2019
A few months ago Apple announced the upcoming version of its desktop OS macOS Catalina, which is going to replace the default command line shell bash
with zsh
for all newly created accounts. This was the start of my “adventure”. It wasn’t so long, however it was full of pitfalls. So I came here in the hope to save a few hours for someone.
First of all lets change a command line shell for your user. To do that we need locate zsh
and set as default shell:
# get path to `zsh` on your machine and use it with `chsh` command
$ which zsh
/bin/zsh
$ chsh -s /bin/zsh $USER
Restart Terminal.app and make sure that your changes applied:
$ ps -p $$ -oargs=
-zsh
Now we can make some customizations. Every day I operate with git
from terminal so there are two important things for me: git-prompt and git-autocomplete. Zsh provides git-autocomplete out of the box. So there is some commands to set up prompt:
$ cd ~/
$ curl -o .git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
$ touch ~/.zshrc
We almost done 😁 Open ~/.zshrc
in your favourite text editor and put there:
#!/bin/zsh
# Set up git-prompt
source ~/.git-prompt.sh
setopt PROMPT_SUBST; PS1='%~ $(__git_ps1 "(%s)")\$ '
autoload -U compinit; compinit
# If you have aliases or $PATH extensions in your .bash_profile paste it below
Restart your terminal one more time and enjoy your new shell.
Posted on October 1, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.