Install and configure iTerm2 on a Mac in 2021

Kristofer Lundgren
3 min readApr 26, 2021

--

iTerm2 is a terminal app on the Mac that has many feature not available in the default Terminal app. The feature I find most useful is, continuously highlighting words matching a regular expression. Ex. [Ee]rror, [Ww]arning etc. But it has many other features you may enjoy.

Prepare the installation of iTerm2

  • First, make sure the package manager Homebrew is installed.
    If not , please install Homebrew. See https://brew.sh/.
  • Second, update Homebrew and associated apps:
    In a terminal, run:
    brew upgrade

Install iTerm2

To install iTerm2, run this in a terminal:
brew install --cask iterm2

Start the iTerm2 app from Spotlight by pressing Command–Space bar, and type iterm. Choose iTerm and press enter.

Configure iTerm2

These settings are my personal preferences, that I have been using the last couple of years. Please walk through the settings, and see what suits you.

Menu -> iTerm2 -> Preferences… -> Appearance -> Windows:
Show border around windows: Enable

Menu -> iTerm2 -> Preferences… -> Appearance -> Tabs:
Show tab bar even when there is only one tab: Enable
Stretch tabs to fill bar: Disable

Menu -> iTerm2 -> Preferences… -> Appearance -> Dimming:
Dimming amount: Set to ca 50%
Dim background windows: Enable

Menu -> iTerm2 -> Preferences… -> Profiles -> Colors:
Color Resets: “Pastel (Dark Background)“
Minimum Contrast: Move to 75%

Menu -> iTerm2 -> Preferences… -> Profiles -> Window:
Columns: 160
Rows: 50

Menu -> iTerm2 -> Preferences… -> Profiles -> Terminal:
Unlimited scrollback: Enable
Silence bell: Enable
Flash visual bell: Enable

Menu -> iTerm2 -> Preferences… -> Profiles -> Session:
After a session ends: No Action
Automatically log session input to file in: Enable
- Run mkdir -p ~/Documents/logs/iterm2 in a terminal and choose that directory for the log files.

Menu -> iTerm2 -> Preferences…
-> Profiles -> Advanced -> Triggers, Edit:

Add these triggers to highlight certain important segments of text:
"[Ee]rror" — Highlight Text — Text:ffffff — Background:7b0000 — No
"[Ww]arning" — Highlight Text — Text:ffffff — Background:955555 — No
"[Dd]eprecated" — Highlight Text — Text:ffffff — Background:955555 — No
"[Tt]erminated" — Highlight Text — Text:ffffff — Background:955555 — No
"[Ff]ailed" — Highlight Text — Text:ffffff — Background:955555 — No

Add this trigger to highlight the terminal prompt:
"^[^ ].*[>#$%] $" — Highlight Text — Text:ffffff — Background:Transparent — Instant=Yes

Menu -> iTerm2 -> Preferences… -> Advanced:
Mouse, Scroll wheel sends arrow key when in alternate screen mode: Yes
Session, Suppress restart session confirmation alert: Yes

Menu -> iTerm2 -> Install Shell integration:
- Press Continue.
- Press Download and Run Installer.
- Press Continue to finalize the Shell integration.

Zsh & bash configuration

Optionally, you may want to configure your zsh & bash shell settings.
Please see this article for some instructions:
Installing-a-new-apple-mac-in-2021

Finally

Open an iTerm2 terminal window.
Press Command-plus/minus to get a comfortable font size.

Enjoy!

--

--

Kristofer Lundgren

A systems engineer using DevOps principles on a daily basis.