DEV Community

Cover image for macOS awesome terminal
Ran Cohen
Ran Cohen

Posted on • Edited on

macOS awesome terminal

Hello developers πŸ§‘β€πŸ’», thanks for reading my post πŸ™.

A shell is a user interface for access to an operating system’s services. Most often the user interacts with the shell using a command-line interface (CLI). The terminal πŸ’» is a program that opens a graphical window and lets you interact with the shell.

As developers, one of the programs we use most is our terminal, and as such it should allow us to be as productive and fast as possible πŸš€ as well as to show off its features and pretty look 😎.

So let's embark on a journey 🧭 to make our terminal in macOS no less awesome πŸ™Œ.


iTerm2

iTerm2 logo

Initially, we will replace the preinstalled terminal for iTerm2, which has tons of very useful features.

  • Go to iTerm2 download page and downloaded the stable release.
  • After the download is complete, drag the file to the Applications folder.
  • Bonus: Place iTerm2 in a convenient place in the dock (replace the original terminal if you already have it there).

iTerm2 has a standalone update mechanism so I prefer to install it manually rather than through a brew cask.

Oh My Zsh

Oh My Zsh logo

Next, let's unleash our terminal by installing Oh My Zsh.

Oh My Zsh is an open source, community-driven framework for managing your Zsh configuration.

Oh My Zsh comes bundled with plugins that'll make your life as a developer easier and leave you feeling like a superhero.

To enable a plugin add its name to the plugins array in your .zshrc file (found in the $HOME directory).
Here are some that I highly recommend:

plugins=(alias-finder brew common-aliases copypath copyfile docker encode64 git history jsontools macos web-search z)
Enter fullscreen mode Exit fullscreen mode

When installing Zsh's theme and plugins, opt for oh-my-zsh installation (... which is actually a git clone of the plugin's repo into the $ZSH_CUSTOM folder and a setting change in .zshrc). It will play best with the other settings in .zshrc, and the autoupdate plugin will keep them up-to-date.

Zsh Theme

My choice of theme for Zsh is Powerlevel10k. Beyond being fast and minimal, it has maintained its popularity for many years and continues to improve with each new version. Also, I'm totally in favor of installing the recommended font that comes with it.

Zsh plugins

  • autoupdate-zsh-plugin: Auto update git-repositories in $ZSH_CUSTOM folder. This plugin is crucial because it keeps the rest of the plugins up-to-date.
  • zsh-syntax-highlighting: It enables highlighting of commands while they’re typed. This helps in reviewing commands before running them, particularly in catching syntax errors.
  • zsh-autosuggestions: It suggests commands as you type based on your history and completions.
  • zsh-history-substring-search: Type in any part of any command from your history, and then press chosen keys, such as the UP and DOWN arrows, to cycle through matches.
  • zsh-nvm: Zsh plugin for installing, updating and loading nvm. nvm installation is relevant for developers working with node.js. This plugin is recommended since nvm via brew isn't supported.

iTerm2 Elevation

To open the preferences at any stage, Open iTerm2 β†’ Press (command) ⌘ + , (comma).

Shell Integration

Enabling the shell integration feature enables many useful features by itself.
Follow the official documentation instructions.
In practice the steps should look something like this: install-shell-integration-1 install-shell-integration-2

Key Mappings

Setting these key mappings allows us to use common keyboard shortcuts in our terminal.

Follow the instructions in the gist I made for this purpose, and if you found it helpful, I'd appreciate you giving it a star as well.

Hotkey

Setting a hotkey allows us to show or hide iterm window even if another application is active.

  • Preferences β†’ Keys β†’ Hotkey β†’ β˜‘οΈ Show/hide all windows with a system-wide hotkey
  • Click on the rectangle that appears right to "Hotkey:" β†’ Set your preferred key sequence hotkey-setting

Status Bar

Setting up the status bar allows us to get up-to-date information about the environment we're working in.

  • Preferences β†’ Profiles β†’ Session β†’ β˜‘οΈ Status bar enabled
  • Click Configure Status Bar button to begin setting up your status bar configuration. My active components are: CPU Utilization, Memory Utilization and Network Throughput my-status-bar

Remove the last login: ... line on top of each new window

cd ~; touch .hushlogin
Enter fullscreen mode Exit fullscreen mode

Allow iTerm to access administrative files

  • System Preferences β†’ Security & Privacy β†’ Full Disk Access β†’ β˜‘οΈ iTerm.app

Use TouchID for sudo execution

  • Open /etc/pam.d/sudo with a text editor as admin
sudo vim /etc/pam.d/sudo
Enter fullscreen mode Exit fullscreen mode
  • add auth sufficient pam_tid.so line on top and save /etc/pam.d/sudo
  • Preferences β†’ Advanced β†’ Allow sessions to survive logging out and back β†’ Select "No"

Set some "nice to have" preferences

  • General β†’ Closing β†’ β˜‘οΈ Quit when all windows are closed
  • General β†’ Selection β†’ β˜‘οΈ Double-click performs smart selection
  • General β†’ Window β†’ β˜‘οΈ Smart window placement
  • Appearance β†’ General β†’ Theme β†’ Select "Minimal"
  • Appearance β†’ Tabs β†’ β˜‘οΈ Show tab bar even when there is only one tab
  • Profiles β†’ General β†’ Icon (Basics) β†’ Select "Built-in Icon for Current App"
  • Profiles β†’ General β†’ Working Directory β†’ πŸ”˜ Advanced Configuration β†’ Edit... β†’ Working Directory for New Split Panes β†’ πŸ”˜ Reuse previous session's directory
  • Profiles β†’ Text β†’ Cursor β†’ πŸ”˜ Vertical bar + β˜‘οΈ Blinking cursor
  • Profiles β†’ Text β†’ Font β†’ Increase size (I use 16 as in my IDE)
  • Profiles β†’ Terminal β†’ Shell Integration β†’ ☐ Show mark indicators
  • Keys β†’ Navigation Shortcuts β†’ Shortcut to choose a split pane β†’ Select your preferred option (I use βŒ₯ Number)
  • Pointer β†’ General β†’ β˜‘οΈ Focus follows mouse
  • Advanced β†’ Mouse β†’ Scroll wheel sends arrow keys when in alternate screen mode β†’ Select "Yes"

Add a screensaver

  • CMatrix shows text flying in and out in a terminal like as seen in "The Matrix" movie.
brew install cmatrix
cmatrix
Enter fullscreen mode Exit fullscreen mode
brew install pipes-sh
pipes-sh
Enter fullscreen mode Exit fullscreen mode

Install useful command-line tools

GitHub logo agarrharr / awesome-cli-apps

πŸ–₯ πŸ“Š πŸ•Ή πŸ›  A curated list of command line apps


The Result ✨

configuration files (.zshrc, iterm-profile.json etc..) as a gist

result

Top comments (2)

Collapse
 
kushagrarora17 profile image
Kushagr Arora

Great post!
Please consider updating plugins as I received this message after installation:
Thecopydirplugin is deprecated. Use thecopypathplugin instead.

Collapse
 
rannn505 profile image
Ran Cohen

Done. Thanks for catching that πŸ™πŸΌ.