Technology

I setup my terminal for max productivity

You may have heard the news, but last week I started a new job at Pinterest 📌!

Me with my Pinterest Swag

That’s not what this post is about, but it’s related because I had to set up my new Macbook. I had to remember everything I did 2 years ago to set up my last one, plus add in a few more new things I wanted to try.

This post is about sharing how I set up my terminal and commands you may not know about that you might find useful.

Previously I wrote the Top 7 workflow tips I wish I knew sooner. It covered my terminal setup at a high-level along with other tools I use, but this article will be a full deep-dive into purely my terminal setup and what you might find valuable.

To highlight the importance of optimizing the things you use on a daily basis, here’s a formula that shows 1 hour/day efficiency gain = 1 month saved per year.

1 hour per day x 5 days per week x 52 weeks = 260 hours saved per year

260 hours / 8 hours per day = 32.5 work days per year.

So if any combination of the tips in this article can save you 1 hour, or close to it, you can get a full month of working hours back this year!

  • Terminal app, shell, and plugin manager

  • Theming

  • Best terminal plugins

  • Aliases and history config

  • Command line utilities to install

Let’s dive in 🚀

  • Install iTerm2. This terminal application allows much more customization than the default Terminal application that comes with Mac’s.

  • Use `zsh` instead of `bash`. `zsh` is a replacement for `bash`, which is the type of shell you use.

    • You can run `echo $SHELL` in your terminal and you should see `/bin/zsh` if you’re using zsh. It’s roughly a superset of what bash provides, and allows you to integrate into a plugin system, `oh-my-zsh`.

  • Install oh-my-zsh. This is the plugin manager that allows you to easily optimize your zsh config in `.zshrc`. For example, further down, we’ll discuss plugins that allow you to easily auto-complete past commands you’ve typed, saving you hours of typing time.

    • How to install: `sh -c “$(curl -fsSL https://install.ohmyz.sh/)”`

    • Note: Running the install command overwrites your existing .zshrc file. You can access your old .zshrc file and copy any configuration over through .zshrc.pre-oh-my-zsh

The theme colors you get look sleek like this:

How material design colors look after installing into iTerm2
  • Starship → Used to customize the terminal prompt like this:

Command prompt is directory, then branch, then git status

To get it to look like this, I use the following config:

// ~/.config/starship.toml

format = "$directory$character$git_branch$git_status"
add_newline=false

[git_status]
stashed = ''

It results in a simple prompt of the directory, followed by the branch, followed by the git status.

There are plenty of other options you may be interested in too. Check out all of them.

Finally, you may be interested in some of the presets available to make it easier.

Earlier, we installed the plugin manager `oh-my-zsh`.

Below, we’ll discuss my favorite plugins. You can find most plugins here.

  1. git – The git plugin adds aliases for git commands. A few that I use are:

    1. ga => git add

    2. gc => git commit

    3. gd => git diff

    4. gst => git status

    5. gps => git push

    6. gpl => git pull

  1. zsh-autosuggestions – This prepopulates your current prompt with the closest past command you entered, allowing you to hit “right arrow” to automatically finish and dramatically reduce your typing. Its essentially Github Copilot for your terminal. It’s a must have.

    Commands are prepopulated. Hitting “right arrow” completes it.
  2. zsh-syntax-highlighting – Highlights the commands you type to tell you if its valid or not. For example, `brew` will be red if homebrew isn’t installed, but it will be green if `brew` is installed as you type it.

  3. zsh-completions – This adds additional “completions”, essentially allowing you to hit “tab” to more accurately finish the command you are typing.

  4. SCM Breeze for numbered git shortcuts

SCM Breeze isn’t an oh-my-zsh plugin, but you can install it easily.

Files are annotated with numbers to more easily refer to them

You can refer to your files like `git add 2-3` now or `git reset 1`

See the example below:

Usage example of Git SCM, referring to numbered shortcuts

Note: You can also use the `ll` command to use SCM breeze with non git files.

Using the `ll` command to get SCM commands for files not in `git status`.

This is what my plugins array looks like in .zshrc:

plugins=(
  git
  zsh-completions
  zsh-autosuggestions
  zsh-syntax-highlighting
)

Some plugins, like `zsh-completions` have additional installation instructions though. Please refer to the official page I linked above if you’re interested in using it.

I use the following aliases in my `~/.zshrc` file so I can quickly access the file I need. You can pick which ones you like and name them to your liking.

# Open up zshrc file to edit it
alias addalias='code ~/.zshrc'

# Reload zshrc file to apply changes.
# Allows you to not need to restart terminal for changes to .zshrc to be applied
alias reload='source ~/.zshrc'

alias gs='git status'

alias ohmyzsh="cd ~/.oh-my-zsh"
alias starshipconfig="code ~/.config/starship.toml"

# navigate to global ssh directory
alias sshhome="cd ~/.ssh"

# edit global ssh configuration
alias sshconfig="code ~/.ssh/config"

# edit global git configuration
alias gitconfig="code ~/.gitconfig"

Another addition I make is to history-based configuration, credit to this article

HISTFILE="$HOME/.zsh_history"
# Display timestamps for each command
HIST_STAMPS="%T %d.%m.%y"

HISTSIZE=10000000
SAVEHIST=10000000

# Ignore these commands in history
HISTORY_IGNORE="(ls|pwd|cd)*"

# Write the history file in the ':start:elapsed;command' format.
setopt EXTENDED_HISTORY

# Do not record an event starting with a space.
setopt HIST_IGNORE_SPACE

# Don't store history commands
setopt HIST_NO_STORE

Many of the default unix commands have better, more modern alternatives. Below is a list of my favorites. Grab the code snippet at the end of the list to install all of these.

Credit to

and his post here for exposing me to some of these.

  • gh → GitHub CLI

    • How I use it: To create and checkout pull requests, primarily with `gh pr create` and `gh pr checkout`

    • How to install it: `brew install gh`

  • bat → Improvement on `cat` command.

    • How I use it: Instead of `cat`. It gives nicer to read output with syntax highlighting. I also set the theme in .zshrc by adding `export BAT_THEME=”base16″`

    • How to install it: `brew install bat`

  • bottom → Graphical system monitor in your terminal.

    • How I use it: Quickly assess what is taking the most memory and CPU. Run with `btm`.

    • How to install it: `brew install bottom`

  • jq → Query JSON data for exactly what you need

    • How I use it: If I have a big JSON file and want to transform the shape of it by only selecting certain parts.

    • How to install it: `brew install jq`

  • fzf → Interactive fuzzy finder

    • How I use it: I should probably use this more, but in general it’s nice to have around for quickly checking files that match a certain pattern.

    • How to install it: `brew install fzf`

  • fd → `find` replacement

    • How I use it: As an alternative to `find`. It’s faster and I hook it up to `fzf`

    • How to install it: `brew install fd`

  • ripgrep → `grep` replacement. Use via `rg` command.

    • How I use it: Use it instead of grep. It’s faster and respects gitignore & hidden files. It can also do text replacement with a –replace flag.

    • How to install it: `brew install ripgrep`

  • tldr → `man` replacement

    • How I use it: Instead of `man `. Easier to read output at a glance.

    • How to install it: `brew install tlrc`

  • mcfly → Better `ctrl + r` reverse search

    • How I use it: Install it and forget. It replaces ctrl + r with a better search functionality

    • How to install it: `brew install mcfly`

  • procs → Alternative to `ps` command, with memory and CPU output

    • How I use it: Cleaner output than `ps`. I can also tell which processes are hogging up memory and CPU at a glance.

    • How to install it: `brew install procs`

There are a few I have installed but haven’t found the opportunity to use yet, but I can see being useful:

  • sd → simpler `sed` alternative. Easier APIs

    • How I would use it: Replace text patterns in files. `sed` has always been a pain to use when I write scripts using it.

    • How to install it: `brew install sd`

  • broot → Interactive file and directory explorer

    • How I would use it: Apply a command to a specific set of files for more complex searching and assessing cases.

    • How to install it: `brew install broot`

  • httpie or curlie → curl replacement

    • How I would use it: As a nicer alternative to `curl`

    • How to install it: `brew install httpie` or `brew install curlie`

  • hyperfine → benchmarking tool to quickly benchmark a command or program

    • How I would use it: Assess how long a script will take to run, usually to assess it in CI. Most commands output the time it took, but this is useful for the ones that don’t, especially after an upgrade.

    • How to install it: `brew install hyperfine`

Here’s a single command to get all of these

brew install 
  gh 
  bat 
  bottom 
  jq 
  fzf 
  fd 
  ripgrep 
  tlrc 
  mcfly 
  procs 
  sd 
  broot 
  httpie 
  curlie 
  hyperfine

There are still improvements I want to make and I’m working up to.

  • I want to try out Tmux for window management

  • Add ai-shell or shell-gpt to my terminal to get ChatGPT in my terminal

I’ve picked up many of these tricks over the years through various sources.

A few articles that I’ve learned from are:

I’m experimenting with a High Growth Engineer job board for a few weeks. This week I am selecting 1 remote and 2 hybrid jobs to highlight. Note: I do get a commission if you’re hired.

  • Check me out on the Science Speaks Podcast: I had an amazing time with Mark Bayer, former U.S. Senate Chief of Staff. We gave actionable advice to improve your communication and I shared personal stories that taught me some of the most important lessons that shaped me. A must listen (only 12min at 2x speed)!

  • What did I even do this week besides meetings!? by

    on — Understand the multiple dimensions of where impact can come from and learn actionable force multipliers.

  • How you start a new role influences your success in that role by

    on — I appreciated this read as I was starting at Pinterest this week. It helped me with my mindset and approach for the first week.

Thank you for your continued support of the newsletter and the growth to 56k+ subscribers 🙏

– Jordan

P.S. Here are a few other things which may interest you:

  1. Path to Senior Engineer Handbook (9.3k+ stars)—Everything you need to get to Senior. Let’s get to 10k stars!

  2. My LinkedIn: I write daily content to 60k+ engineers. I’m also ramping on Twitter/X

  3. Newsletter sponsorships: Feel free to reply to this email or check the Sponsorship packages

Did you find this issue valuable? If so, there are two ways you can help:

You can also hit the like ❤️ button at the bottom of this email to help support me or share this with a friend to get referral rewards. It helps me a ton!

Related Articles

Back to top button