Return to site

Iterm2 Zsh

broken image


ITerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + Powerlevel10k - (macOS) - iterm2-solarized.md.

  1. Iterm2 + Zsh
  2. Zsh Vs Iterm2
  3. Iterm2 Zsh Theme
  4. Iterm2 Zsh Colored Tabs

My terminal emulator and shell setup for macOS, Linux, and Windows. AKA 'Ultimate Terminal Setup'

Iterm2 Zsh
2020 update note: Follow me on Patreon to get updates when I build this into more of a video tutorial, which some have wanted me to call 'Shell Mastery' 😂

My Terminal Setup: iTerm + Zsh. As a follow up to my post on my text editor setup, I wanted to write about the other key part of my development setup - my terminal. Unlike my relatively new text editor setup, my terminal configuration has followed me around for years - spanning over multiple jobs and even more computers. A protip by ducknorris about shell, zsh, mac os x, and iterm2.

Terminal Emulator

The GUI that emulates a text terminal, and runs a shell

  • macOS: iTerm2
  • Linux: Tilix
  • Windows 10: Windows Terminal
  • Windows 7/8: cmder

Shell and Prompt

Z shell (zsh) is my favorite. Here's how to make it awesome

  • macOS: Now the default in 10.15+ at /bin/zsh or manually install a newer version with brew install zsh to /usr/local/bin/zsh. Default is fine in 99% of cases
  • Linux: If which zsh shows nothing, then install with apt/yum/apk. Next, change your login shell with chsh -s $(which zsh)
  • Windows 10: I recommend WSL/WSL2 with Ubuntu and zsh installed there, rather than a zsh.exe alternative
  • Zsh 'Configuration Manager':Oh-My-Zsh adds a bunch of bonus features and plugins to your shell. Check their GitHub wiki for more info and how to customize
  • Oh-My-Zsh has themes, which mostly affect the prompt features like git branch, current directory, etc. but also has colors you can tweak (see below)
  • Here's my custom Zsh prompt theme with 🐳 and 'presentation mode' option

Colors

I like having matching true-color themes in all my shell apps

  • GruvBox is my default for everything. I'm now using the community fork which is better maintained. It supports light and dark modes, as well as various contrast options. The contrib repo has the theme for different app formats, including iTerm2, SpaceVim, Tilix, and tmux.
  • True Color enabled in iTerm2, Zsh, and Vim. Also check the Gruvbox notes on true color
  • Assuming you're using Oh-My-Zsh above, you can replace the default theme in .zshrc env ZSH_THEME with this Gruvbox colored one, or just tweak the colors of the full theme list. This really only affects the prompt, not the terminal colors, which are controlled by your terminal emulator
  • INSANE Wild Cherry theme. I love this, but is it a daily theme? Not sure

Shell Editor

I prefer neovim (fork of vim), but any vim will do

  • Neovim (install info), which you run as nvim once installed
  • Plugin Manager:SpaceVim makes good feature-rich defaults (works with both vim/nvim). I love it and it's the only way I vim

Fonts

Some fonts are designed for shells and programming. I only use those

  • Nerd Fonts takes those popular programming fonts and adds extra glyphs and icons for better support in shell tools
  • I prefer using Homebrew to install those fonts on macOS and Linux. You can always just download one or all of them from Nerd Fonts and usually just dbl-clicking a font file in macOS or Windows will install it
  • One of my favorite fonts: Sauce Code Pro Font from Nerd Fonts which gives me Vim + Powerline + icons. That's all you need, but if you're curious: It's based off another mod to support this font with Powerline in VIM, which itself is based off the original Adobe Source Code Pro open source font. Whew, what a rabbit hole 😵
  • Italics enabled in iTerm/Vim. It makes comments easier to visualize I think

Other Essentials

Iterm2 + Zsh

  • Tmux for shell session management (most of this stuff works in Tmux)
  • Oh-My-Tmux for much better default Tmux setup. It's great out-of-the-box
  • Mosh for better SSH that auto-reconnects and uses UDP for slow/laggy/lossy
  • SilverSearcher (ag from cli) for better shell code search
  • bat for color cat output of code and markdown (syntax highlighting)

As a software engineer, we spend significant amount of time in terminal. Terminal in Mac OSX is better than windows but not as good as iTerm2. If you combine iTerm with Zsh and Oh-My-Zsh then what you get is awesomeness.

Install iTerm2

Download a stable build from https://www.iterm2.com/downloads.html and install it.

Install Brew

Zsh Vs Iterm2

Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's macOS operating system.

Now, open iTerm and install brew using following command:

Install and Configure Fira Code Font

Fira Code is an extension of the Fira Mono font containing a set of ligatures for common programming multi-character combinations. This is just a font rendering feature: underlying code remains ASCII-compatible. This helps to read and understand code faster.

Without Fira Code

With Fira Code and Ligature

To install Fira Code, run following command:

ProTip: Fira Code font is supported in multiple editors and terminals. Checkout complete list on Fira Code site

Setup Font in iTerm

Step 1. Open Preferences in iTerm by pressing and , keys

Step 2. Go to Profile tab and create a new profile Xiaomi redmi note 5 64gb.

Step 3. Go to Text tab. Change font and ASCII font to Fira Code and enable use of ligature

Install Zsh

Once you have brew installed, you can install zsh using following command:

Install and Configure Oh-My-Zsh

Oh-My-Zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes and much more.

Install Oh-My-Zsh using following command:

Set Theme

There are whole lot of themes to choose from here. My personal customized theme is based on bira theme.Change ZSH_THEME=robbyrussell to ZSH_THEME=YOUR_FAV_THEME_NAME into ~/.zshrc file. After change reload shell by:

Enable plugins

Iterm2 Zsh Theme

There's an abundance of plugin in Oh-my-zsh. You can find list of plugins here.Most of the plugins provide autocompletion for command options on press of ⇥ tab key (demo). You can turn on plugins by updating plugins section in ~/.zshrc file like following:

Install zsh syntax highlighting and auto suggestions plugins if you are interested in these functionality.

Add following lines to end of the ~/.zshrc file. You can pick and choose from last 3 lines, based on the plugin you have installed.

ProTip: To reload any change made in ~/.zshrc file, use source ~/.zshrc command.

Working with Alias

Alias is not exclusive functionality of zsh but Oh-my-zsh provides lots of alias by default. Lots of plugins also come with alias for example git plugin.

If you want to create your on aliases, create a separate file and load that file using ~/.zshrc by adding following line in the file:

Iterm2 Zsh Colored Tabs

To list all the avaliable alias use command alias in the terminal.

HotKeys

If your hotkeys for moving backward (⌥ option + ) and forward (⌥ option + ) word by word do not work in iTerm then change keys preset in your profile to Natural Text Editing. 3 will be free ep 10 24.





broken image