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
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
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)
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:
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
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
Remove the last login: ...
line on top of each new window
cd ~; touch .hushlogin
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
- add
auth sufficient pam_tid.so
line on top and save - 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
- pipes.sh shows animated pipes.
brew install pipes-sh
pipes-sh
Install useful command-line tools
agarrharr / awesome-cli-apps
π₯ π πΉ π A curated list of command line apps
The Result β¨
configuration files (.zshrc, iterm-profile.json etc..) as a gist
Top comments (2)
Great post!
Please consider updating plugins as I received this message after installation:
The
copydirplugin is deprecated. Use the
copypathplugin instead.
Done. Thanks for catching that ππΌ.