How to setup iTerm2 for development in 2024
iTerm2 is the best terminal app for MacOS (You can't argue with me on this topic). If you're visiting this page, chances are that you're looking to make your iTerm2 even better, more beautiful and fun to work with. In this post, I'll walk you through how I supercharge my iTerm2. Let's dive in!
oh-my-zsh
Oh My Zsh is a delightful, open source, community-driven framework for managing your Zsh configuration. To install Oh My Zsh, run this command in your iTerm2
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
And you can already see, it instantly looks much better
powerlevel10k
powerlevel10k is an Oh My Zsh theme that is fast, flexible and brings great out-of-the-box experience.
To install this theme for oh-my-zsh, you first need to clone the repository
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Then set ZSH_THEME="powerlevel10k/powerlevel10k"
in ~/.zshrc
.
And run source ~/.zshrc
to activate new configurations. This will start the Powerlevel10k configuration wizard. It will walk you through different settings for the theme, including installing the recommended file, setting up prompt format, etc. Feel free to choose what you like at this step.
After the setup is completed, your terminal probably would look like this.
Neat, right!!! However, the text colors are still a bit pale (to my taste), and the command (e.g., brew
) is not highlighted. Let's improve it.
zsh-syntax-highlighting
zsh-syntax-highlighting
is a plugin that provides syntax highlighting for zsh. It highlights the commands as you type them into the terminal.
Install the package via Homebrew with
$ brew install zsh-syntax-highlighting
Then enable the plugin by sourcing the script
echo "source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
zsh-autosuggestions
zsh-autosuggestions
suggests commands as you type based on history and completions.
To install this plugin for your oh-my-zsh, first clone its repository to zsh plugins directory
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc
):
plugins=(
# other plugins...
zsh-autosuggestions
)
Run source ~/.zshrc
to activate the new configurations.
The try to type something and see how it boostraps your productivity 😄.
Material Design Scheme
As I said above, the text colors of our iTerm2 still look a bit pale to my taste. To fix this, I'm going to use the Material Design color scheme for my iTerm. I think it's a pretty beautiful scheme.
You can follow the instructions here to use this scheme for your iTerm2.
One more thing!
The last thing I want to include in this guide is fzf
-- a fuzzy-search plugin that brings much better experience when you search for files, command history in your terminal.
First, install fzf using Homebrew
$ brew install fzf
Then set it up for zsh using
source <(fzf --zsh)
Then you can try to search for command history and see how it gets much better with fzf
. Type Control + R
, then try some command.
That's it! We have gone from a default iTerm2 to a more beautiful, joyful and convenient iTerm2.