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. Inside brew can found the CLI app and utilities. Inside cask are all the applications with Graphical Interface.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew tap homebrew/cask-fonts
brew update
brew upgrade
brew cleanup
Run this command, and follow doctor recommendations:
brew doctor
Permissions
Add permissions to user (or group) under this folders and enclosed items:
sudo chown -R $(whoami) /usr/local/opt
sudo chown -R $(whoami) /usr/local/share
WARNING: Add the next permission just in case your machine is used by only one user.
sudo chown -R $(whoami) /usr/local/lib
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/robbyrussell/oh-my-zsh/master/tools/install.sh)"
git clone https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/nobeans/zsh-sdkman.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/sdkman
brew install zsh-history-substring-search
brew install zsh-syntax-highlighting
brew install z
brew install tree
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
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor root line)
ZSH_HIGHLIGHT_PATTERNS=('rm -rf *' 'fg=white,bold,bg=red')
plugins=(
brew
git
gradle
ng
npm
yarn
zsh-autosuggestions
osx
sdkman
history-substring-search
)
alias x="exit"
alias reload="source ~/.zshrc"
alias hc="history -c"
alias hg="history | grep "
#Include Z
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
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 with sz
command alias or 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 > Preferences > 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.shell.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:
alias x="exit"
alias sb="source ~/.bash_profile"
alias hc="history -c"
alias hg="history | grep"
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
Open terminal and change Terminal > Preferences > 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.
Become a ZSH Ninja!
Highly recommend taking this FREE course made by @WesBoss:
CheatSheet (Key Shortcuts)
The common MacOS modifier keys are:
Command | Control | Option | Shift |
---|---|---|---|
⌘ |
⌃ |
⌥ |
⇧ |
By default, word jumps and word deletions do not work. To enable these, go to iTerm > Preferences > Profiles > Keys > Load Presets…
and select Natural Text Editing
.
Basic Actions
Shortcut | Function |
---|---|
⌥ + → or ⌥ + ←
|
Word jumps |
⌥ + backspace
|
Word deletion |
⌃ + d
|
Delete current character |
backspace |
Delete previous character |
⌃ + -
|
Undo |
⌘ + backspace
|
Entire line deletion |
⌘ + k
|
Clear entire screen |
Moving Faster
Function | Shortcut |
---|---|
⌃ + a
|
Move to the start of line |
⌃ + e
|
Move to the end of line |
⌥ + f
|
Move forward a word |
⌥ + b
|
Move backward a word |
Copy and Paste
Function | Shortcut |
---|---|
⌃ + k
|
Copy from cursor to the end of line |
⌥ + d
|
Copy from cursor to the end of word |
⌥ + backspace
|
Copy from cursor to the start of word |
⌃ + w
|
Copy from cursor to previous whitespace |
⌃ + w
|
Paste the last copied text |
⌥ + y
|
Loop through and paste previously copy text |
⌥ + .
|
Loop through and paste the last argument of previous commands |
Tabs & Windows
Function | Shortcut |
---|---|
⌘ + Enter
|
Fullscreen |
⌘ + Left Arrow
|
Previous Tab |
⌘ + Right Arrow
|
Next Tab |
⌘ + Number
|
Go to Tab |
⌘ + ⌥ + Number
|
Go to Window |
⌘ + ⌥ + Arrow
|
Go to Split Pane by Direction |
⌘ + ] or ⌘ + [
|
Go to Split Pane by Order of Use |
⌘ + ⇧ + d
|
Split Window Horizontally (same profile) |
⌘ + d
|
Split Window Vertically (same profile) |
⌥ + ⌘ + ⇧ + h
|
Split Window Horizontally (new profile) |
⌥ + ⌘ + ⇧ + v
|
Split Window Vertically (new profile) |
⌘ + ⇧ + m
|
Set Mark |
⌘ + ⇧ + j
|
Jump to Mark |
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
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: