avatar

ShinChven's Blog

iTerm2 Hacking Notes

iterm22021-12-18 07:00:50

iTerm2 has always been my favorite terminal. I use it for everything from my development work to regular usage. Here's my note to setup my iTerm2 preferences.

Installation

brew install iterm2

Install Newest zsh Release From HomeBrew

zsh is the default shell for macOS since macOS 10.14. Its version is managed by OS, I would like to use the latest version, so I choose install it from HomeBrew.

brew install zsh ## Install `zsh`
where zsh ## find installation path
chsh -s /opt/homebrew/bin/zsh ## change shell to `zsh` installed from HomeBrew

Install Starship

Starship is a minimal, blazing-fast, and infinitely customizable prompt for any shell!

I use it for:

  • Git prompt
  • Development environment prompt
  • Shell Theme
brew install starship
echo 'eval "$(starship init zsh)"' >> ~/.zshrc
source ~/.zshrc

zsh Plugins

brew install zsh-autosuggestions
echo "source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ~/.zshrc
brew install zsh-syntax-highlighting
echo "source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ~/.zshrc
source ~/.zshrc

Color Schemes

Iterm2-color-schemes

Import Color Schemes

  • Download color schemes by clone the repository.
git clone https://github.com/mbadolato/iTerm2-Color-Schemes.git
  • Press ⌘ + , to open iTerm2 preferences.
  • Select Profiles tab.
  • Select Colors tab.
  • Find Color Presets... at the right bottom.
  • Scroll to the end of Color Presets...'s options to find Import....
  • Import all .itermcolors files from the scheme directory of the cloned repository.

Minimal Tab

Minimal Tab shows the same color of current profile's color preset.

  • Press ⌘ + , to open iTerm2 preferences.
  • Select Appearance tab.
  • Find Theme in General secondary tab.
  • Select Minimal.

Transparency

  • Press ⌘ + i to open preferences.
  • Select Window tab.
  • Set Transparency and Blur.

Font

I'd prefer JetBrainsMono Nerd Font.

Nerd fonts for terminal can be install from HomeBrew:

brew tap homebrew/cask-fonts
brew install font-jetbrains-mono-nerd-font

Set Font for Profiles

  • Press ⌘ + , to open iTerm2 preferences.
  • Select Profiles tab.
  • Select Text tab.
  • Select font at Font section.

Natural Text Editing

I would prefer ⌘ + arrow to move cursor, so I have to switch the terminal input Key Mappings preset to Natural Text Editing.

  • Press ⌘ + , to open iTerm2 preferences.
  • Select Keys tab.
  • Select Key Mapping secondary tab.
  • Find Presets... at left bottom.
  • Select Natural Text Editing.