I setup my terminal for max productivity - 9 minutes read
You may have heard the news, but last week I started a new job at Pinterest đź“Ś!
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 managerThemingBest terminal pluginsAliases and history configCommand line utilities to installLet’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-zshThe theme colors you get look sleek like this:
To get it to look like this, I use the following config:
// ~/.config/starship.tomlformat = "$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.
git - The git plugin adds aliases for git commands. A few that I use are:ga => git addgc => git commitgd => git diffgst => git statusgps => git pushgpl => git pull 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.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. zsh-completions - This adds additional “completions”, essentially allowing you to hit “tab” to more accurately finish the command you are typing.SCM Breeze for numbered git shortcutsSCM Breeze isn’t an oh-my-zsh plugin, but you can install it easily.
You can refer to your files like `git add 2-3` now or `git reset 1`
See the example below:
Note: You can also use the `ll` command to use SCM breeze with non git files.
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 italias 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 CLIHow 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 needHow 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 finderHow 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` replacementHow 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` replacementHow I use it: Instead of `manThere 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 APIsHow 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 explorerHow 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 replacementHow 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 programHow 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 managementAdd ai-shell or shell-gpt to my terminal to get ChatGPT in my terminalI’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.
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:
Path to Senior Engineer Handbook (9.3k+ stars)—Everything you need to get to Senior. Let’s get to 10k stars!My LinkedIn: I write daily content to 60k+ engineers. I’m also ramping on Twitter/XNewsletter sponsorships: Feel free to reply to this email or check the Sponsorship packagesDid 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!
Source: Highgrowthengineer.com
Powered by NewsAPI.org