The Journey of Mastering iTerm2

· 3 min read

Compared to Mac’s built-in Terminal, I find iTerm2 to be quite powerful. Here I’ll summarize some settings and tips from my usage experience.

The app has too many complete settings to describe one by one, so I'll only highlight some configurations that I personally consider important

Basic Settings

The terminal will have an immersive experience without a separate header toolbar

https://static.1991421.cn/2022/2022-06-12-102934.jpeg

Badge Settings

Set badges for each profile to distinguish sessions/machines. Note that badge settings are per profile and don’t work for all machines.

https://static.1991421.cn/2022/2022-06-12-103252.jpeg

Default Timestamp Display

Often I want to know the approximate time when commands were executed, so I enable the timestamp display on the right side by default

https://static.1991421.cn/2022/2022-06-12-103529.jpeg

Enable Status Bar

Terminal sessions can display some data information, such as memory usage, battery level, etc.

https://static.1991421.cn/2022/2022-06-12-103741.jpeg

https://static.1991421.cn/2022/2022-06-12-103843.jpeg

Settings Sync/Save

Since I have multiple Mac devices, I want iTerm2 settings to sync automatically across devices. You can configure this by saving the configuration file to iCloud Drive, then loading it in iTerm2 on another Mac.

https://static.1991421.cn/2022/2022-06-12-104334.jpeg

The configuration for iTerm2 should be consistent across multiple Macs

Unlimited Scrollback

Sometimes our terminal error output is very long. If you want to scroll up to see the complete output, you need to configure Unlimited scrollback

https://static.1991421.cn/2022/2022-06-12-105930.jpeg

Cursor Guide Settings

The line where the cursor is located will be highlighted with a different background color

https://static.1991421.cn/2022/2022-06-13-125026.jpeg

https://static.1991421.cn/2022/2022-06-13-125042.jpeg

Color Presets

Recommend coolnight

https://github.com/josean-dev/dev-environment-files/blob/oh-my-zsh-zshrc-config/coolnight.itermcolors

More themes recommended here

https://github.com/mbadolato/iTerm2-Color-Schemes

Integrated Tools

iTerm2 is powerful not only because of its built-in features but also because it can integrate with the following tools to become even more useful

oh my zsh

zsh is a powerful shell, and oh my zsh makes it even better and more beautiful.

  1. Visit the official website
  2. Install and set up the recommended theme
git
git-extras
zsh-syntax-highli
zsh-autosuggestio
autojump
jhipster
docker
docker-compose
spring
cask
macos
colored-man-pages

tmux

tmux can solve session saving/restoration. For detailed introduction, you can check my other summary. Here’s a brief description:

  1. Global settings in iTerm2

https://static.1991421.cn/2022/2022-06-12-104520.jpeg

  1. Install tmux on the target machine
  2. Set commands in profile to enable when logging into the machine

ssh -p 22 -t root@188.146.132.160 "tmux -CC attach || tmux -CC"

https://static.1991421.cn/2022/2022-06-12-104849.jpeg

Alfred

After Alfred integration, you can directly input commands in the input box to trigger iTerm2 execution

  1. Copy script content

  2. Alfred -> Features -> Terminal

    https://static.1991421.cn/2022/2022-06-12-105621.jpeg

Others

Dynamic Profile

When frequently operating multiple server terminals in iTerm2, there’s a problem of how to reuse profile configurations, such as szrz trigger support and key settings.

The solution is iTerm2 Dynamic Profile

Configuration

  1. cd ~/Library/Application\ Support/iTerm2/DynamicProfiles
  2. Create iterm2-profile-template.json
  3. Configure iterm2-profile-template.json. For specific profile configuration items, you can configure a target in the UI, select export to json, and copy the needed configuration items to the template file
  4. UI operation to copy target configuration items
    • Select template profile
      image
    • Select the category items that need to be copied Not all configurations in the current profile support copying
    • Select the target profiles to copy to, multiple selection supported
      image

This solves the problem of profile configuration reuse

Dynamic Profile Parent Name

Profile templates themselves also support dynamic inheritance. The configuration method is the same as above, just with two additional fields Dynamic Profile Parent Name and Dynamic Profile Parent GUID to indicate inheritance relationships

  1. Either name/guid can be configured
  2. Profiles in templates are lists, so pay attention to the configuration placement order: parent first, child inheritance after
  3. GUID generation can use the command line tool uuidgen

Recommended to create a soft link for profiles and sync to cloud drive for easy reuse.

ln -s "$HOME/Library/Mobile Documents/com~apple~CloudDocs/conf/iTerm2/iterm2-profile-template.json" "$HOME/Library/Application Support/iTerm2/DynamicProfiles/iterm2-profile-template.json"

Semantic History

Execute different actions when clicking different files in the iTerm2 terminal. 🚀

Script installation, click here

https://static.1991421.cn/2025/2025-04-25-111821.jpeg

Triggers

For simple file upload and download, using SZRZ is much more convenient than using FileZilla alone

https://static.1991421.cn/2022/2022-06-12-112714.jpeg

https://static.1991421.cn/2022/2022-06-12-112553.jpeg

Final Thoughts

See how powerful iTerm2 is? Let’s get started with it.