There is a before and after listening to these letters together: ZSH. You may wonder: Why did not I hear about this before? D’oh!
Oh My Zsh - a delightful & open-source framework for Z-Shell
ZSH (Z Shell) it’s a real evolution, modernize terminal things with simple solutions. It can be used on GNU Linux and macOS, but I will teach you how to install and configure it on MacOS.
Prerequisites
Homebrew
Brew has his own classification. The inside brew can found the CLI app and utilities. Inside is cask all the application with Graphical Interface.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Add this lines to ~/.bash_profile
and/or ~/.zshrc
file:
# Brew
export BREW_HOME="/opt/homebrew/bin"
export PATH="$BREW_HOME:$PATH"
eval "$($BREW_HOME/brew shellenv)"
Run this commands on terminal:
eval "$(/opt/homebrew/bin/brew shellenv)"
source ~/.zshrc
source ~/.bash_profile
Restart your terminal, then update and upgrade brew sources:
Run this command, and follow doctor recommendations:
brew doctor
The Triplets of Belleville
WARNING: I don’t want presume, but iTerm2 + Oh My Zsh! + Powerlevel10K it’s a lethal combination. You will not want to use another terminal later.
brew install --cask iterm2
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
git clone https://github.com/nobeans/zsh-sdkman.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/sdkman
git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/Pilaton/OhMyZsh-full-autoupdate.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/ohmyzsh-full-autoupdate
chsh -s /bin/zsh
Close the default terminal and open iTerm2.
Configuration
ZSH configuration file is located under ~/.zshrc
. Open with your favorite editor and set:
DEFAULT_USER="$USER"
ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(history)
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
export LS_COLORS="rs=0:no=00:mi=00:mh=00:ln=01;36:or=01;31:di=01;34:ow=04;01;34:st=34:tw=04;34:pi=01;33:so=01;33:do=01;33:bd=01;33:cd=01;33:su=01;35:sg=01;35:ca=01;35:ex=01;32:"
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor root line)
ZSH_HIGHLIGHT_PATTERNS=('rm -rf *' 'fg=white,bold,bg=red')
plugins=(
brew
command-not-found
extract
macos
git
github
gitignore
sdkman
history-substring-search
node
npm
volta
vscode
sudo
web-search
z
zsh-autosuggestions
zsh-syntax-highlighting
ohmyzsh-full-autoupdate
)
# Z Plugin
if command -v brew >/dev/null 2>&1; then
# Load rupa's z if installed
[ -f $(brew --prefix)/etc/profile.d/z.sh ] && source $(brew --prefix)/etc/profile.d/z.sh
fi
source /opt/homebrew/etc/profile.d/z.sh
# Plugins
source /opt/homebrew/share/zsh-history-substring-search/zsh-history-substring-search.zsh
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
Add all the plugins that you want or need inside plugins=()
list, each one in a new line.
Open iTerm2 and after changing the value make sure to update your ~/.zshrc
file running the complete command:
source ~/.zshrc
Fonts
Download and Install Meslo and Nerd Fonts
brew install --cask font-meslo-lg-nerd-font
brew install --cask font-hack-nerd-font
Change it on iTerm > Settings > Profiles > Text > Change Font
and select MesloLGS NF
.
Visual Studio Code
If you want use ZSH as default terminal in Visual Studio Code, add this settings (⌘ + ,
):
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.fontFamily": "Meslo LG M for Powerline",
"terminal.integrated.defaultProfile.osx": "zsh",
Wizard
On the first run, Powerlevel10k configuration wizard will ask you a few questions and configure your prompt.
If it doesn't trigger automatically, type p10k configure
.
Configuration wizard creates ~/.p10k.zsh based on your preferences. Additional prompt customization can be done by editing this file. It has plenty of comments to help you navigate through configuration options.
Terminal (Bash)
macOS default terminal comes with version 3 and not going to update it because the newer version changes his license. Apple does not supply any software under the GPLv3.
Open default terminal and run this command in order to use an updated version:
brew install bash bash-completion
Add this line to ~/.bash_profile
file:
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
Open terminal and change Terminal > Settings > General
on Shell open with:
select Command (complete path)
and set /bin/bash
value.
With this configuration, now you can use ZSH on iTerm2 and Bash on default Terminal.
Remove “Last login:”
For me, it's unnecessary and annoying the default “Last login:” message in the macOS terminal. Happily, it's easy:
touch ~/.hushlogin
Become a ZSH Ninja!
Highly recommend taking this FREE course made by @WesBoss:
Bonus Track
Setup macOS for Development
Camilo Martinez ・ Sep 26 '18
That’s All Folks!
Happy Coding 🖖
Top comments (20)
The Brew installation chaged. Nos this is the command:
Fixed. Thanks for reporting the update! 🤘
Thanks for this!
if you have a 404 problem to install the fonts, search here the solution: github.com/Homebrew/homebrew-cask-...
hi Camilo,
Thank you for this powerful config.
I'm getting this exact same problem as the user suggest here
superuser.com/questions/1061181/it...
I'm not getting the colors theme.
Do you know how to fix it?
Thx.
Hi Gunt, I have no idea.
Can you try with powerlevel10k. See comments below.
And run
p10k config
command. It's like a wizard configuration.Maybe this can help. Let us know if works.
I try with powerlevel10k, I love it already, but the theme colors are not working. I'm still trying to fix it. I will let you know.
There is powerlevel10k now. It's 10 times faster than powerlevel9k and backward-compatible with its configs. You can switch theme without changing any of your
POWERLEVEL9K
options to keep the same prompt you are used to while making it blazingly fast.First, clone powerlevel10k.
Then set
ZSH_THEME=powerlevel10k/powerlevel10k
in your~/.zshrc
and restart zsh.Wow I watched the video and it's amazing.
Works like a charm and
p10k configure
command is the best.Thanks!
Hello,
The initial command:
brew tap caskroom/cask
is not working anymore.Thanks for this step by step.
You welcome.
I'll fix that. I see on documentation that on new versions don't need to install cask anymore, you just need homebrew.
Thanks!
If you can update with PowerLevel10k. It's amazing.
I'll add it as a bonus.
I'm using it actually and it's really fast.
@gabrielizalo finally was updated to
powerlevel10k
I know this is an old one now, but take a look at prezto and powerlevel10k. You might like the results!
Camilo, thank you so much!
I'd been using iTerm + zsh for a years, but even that I've found out something new for me from your post.
Your welcome Dmitriy, do the free course I learned a lot.
what theme are using for iterm2? what about the syntax highlighting
I'm using Powerlevel9k theme: github.com/Powerlevel9k/powerlevel9k
and Syntax Highlight installed with brew:
brew install zsh-syntax-highlighting
I’m talking about the interm2 color scheme, not the oh-my-zsh, sorry for the confusion
No problem, that's my Appearance configuration: