Improving Mac Terminal

Amir Yonatan
2 min readMay 23, 2021

The builtin terminal in OSX is ok, but I found the iTerm2 is better.

After you Downloaded iTerm, and installed it, I found that these customizations are a must:

  • make iTerm2 Default Term
  • Install Shell Integration
  • In PreferencesGeneral → Closing set Quit when all windows are closed
  • In PreferencesGeneral → Closing unset Confirm closing multiple sessions
  • In PreferencesGeneral → Closing unset Confirm “Quit iTerm”
  • In PreferencesGeneral → Services set Check for updates automatically
  • In Preferences → Appearance → General use Dark theme.
  • In Preferences → Profiles → General under Working Directory choose Reuse previous session’s directory. This will change the default behavior when opening a new tab, to start in the current path, and not in the Home Directory.
  • In Preferences → Profiles → Terminal Set Unlimited scrollback

Zsh, Oh My Zsh

Zsh is a new shell that extends the functionality and user experience over the default macOS shell.

If zsh is not installed yet:

brew install zsh

Execute this to install Oh My Zsh:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
touch ~/.z

When finished, I suggest adding 3 more plugins:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlightinggit clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestionsgit clone https://github.com/djui/alias-tips.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/alias-tips

Before we continue to zsh config, install nvm:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash

Then, let’s take a look in Zsh config file:

$ vim ~/.zshrc

Change the current plugins to:

plugins=(git z zsh-autosuggestions zsh-syntax-highlighting alias-tips npm yarn node osx)

And these for nvm:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc

That’s all for now!
I hope you found this post helpful, if you have any comments or any other suggestions let me know.

--

--