Love your CLI a bit more

Petr Miko
Emplifi
Published in
7 min readAug 23, 2024

Let’s face it — as developers we spend a significant amount of time in the terminal. Some people love it, some people hate it, but no matter which group you belong to, I am nearly certain you can try a few recommendations from this article to make your time in the terminal a better experience 🙂

Disclaimer before we start:

  • the steps are my personal favorites and your preferred selection of tools may vary
  • while I tried to target all major operating systems and a broader audience, you can probably tell I am a Node.js developer working in zsh

0. Prepare a package manager

Linux user? Great, you’re all set and can jump to the next section. But for the Windows and MacOS users installing new applications via the terminal can seem a bit intimidating at first. Sure, for the non-juniors among you, this is obvious, but let’s agree that package managers are great as they do the following:

  • Provide a universal interface to operate with the application lifecycle. Find, get info, update, remove… All there. So you can even write a script to set up your machine.
  • Usually edit your environment variables like $PATH, prepare symlinks, so you can use the app without any more tinkering. If not, it tells you what to do.

So what are the options here?

  • 🪟 winget (MS Store or follow the official article)
    - Microsoft’s proprietary solution
    - you can also use WSL → welcome to the Linux world
  • 🍎 Homebrew (official site)
  • 🐧 Homebrew is also an option. Or use your OS’ package manager like dnf.

1. Choose you CLI application

Ok, so you are not using raw Linux terminal with tmux, right. Right?… While there are some default terminal applications in our operating systems and the Linux ones are kinda OK, the Windows and MacOS default terminal apps feel suboptimal. Ugly, old, not offering many shortcuts and/or customizations. Yep, they mostly suck. So the first step is selecting a better application.

  • 🪟 Windows Terminal (MS store or winget install -e — id Microsoft.WindowsTerminal)
    - should be default in Windows 11 by some update, but you can switch yourself in Win10/11 if you’re still stuck with cmd
  • 🍎 iTerm2 (official site or brew install cask iterm2)
  • 🐧 KiTTY (official site or your package manager of choice)

2. Install fonts with icons and ligatures support

Following steps in this article will expect fonts that can show you fancy ligatures and icons in the directory list or next to the name of your current git branch. What is a ligature? See an example in the next picture:

Example of font ligature
Icons in eza output

Head out to Nerd Fonts, make your pick and install some font(s)! My favourite pick is FiraCode Nerd Font.

3. Shell themes and plugins

By now you have your fancy terminal app loaded with great fonts, only the terminal looks are still not tweaked. So it is time to select a Theme manager based on your shell and install it!

  • powershell — Oh My Posh (official site, winget install -e — id JanDeDobbeleer.OhMyPosh, brew install oh-my-posh )
  • zsh — Oh My ZSH (script from official site is the preferred way)

For both, there are plenty of available themes you can pick from, and both rely on storing the configuration in the shell profile/resource file. Follow their respective tutorials closely. Or if you want to just read the article for now, I will provide my example Powershell profile file and zshell configs by the end of it.

But wait! Did I mention plugins? Yes, but only for Oh My ZSH. You can extend its behavior based on any of community available plugins to alter your shell behavior even further. My favorite plugin is history-substring-search — type a few letters that are present in any location of some command you’ve run in the past, press the up arrow button, and bam! You are browsing through history in CTRL+R style with ease!

4. Install all the applications!

Congratulations! You are entering the last yet never-ending task of finding the right CLI application you will use for your daily tasks 🎉. But what are the options? For Unix-like systems, I can recommend looking into Modern Unix list. I am sure you will find some that will catch your eye. But what about Windows? I got some tips even for you.

4.1 Eza

Eza is a Rust-based successor of the no longer maintained exa, so it is basically an ls alternative on steroids. And since it is written in Rust, not only is it blazing fast™, but also cross-platform. Now is the time to list your files with icons and all that Git status information!

  • 🪟 winget install eza-community.eza
# add into Powershell profile file
function EzaAliasBasic { [alias('ls')] param([string]$Path='.')
eza.exe --group-directories-first --icons $Path @Args
}

function EzaAliasList { [alias('ll')] param([string]$Path='.')
ls -l --git $Path @Args
}
  • 🍎/🐧 brew install eza
# .zshrc
alias ls="eza --icons --git --group-directories-first"

4.2 Zoxide

It has been a few years since a colleague of mine introduced me to the convenience and ease of use of an application named autojump. It learns paths you visit by the usual change dir cd traversal, and then you can later auto-jump to that location by typing j plus a few letters in the path…

cd ~/Development/analytics-unified
# vs
j uni

Seems like no big deal, but the time savings! Especially if you need to switch across many repositories. So why am I writing about zoxide in the section heading and then describing autojump? Because zoxide is autojump but better.

Unlike autojump, written in Python, zoxide is written in Rust, thus it does not require any additional software to run as you are installing a binary. You can change the alias from z to j so you can continue with your autojump-grown muscle memory and avoid qwerty/qwertz issues that non-native speakers, like I often face when switching layouts. And you are not losing your history when making the switch to zoxide — you can import autojump’s history. It cannot get any better, right? Well… It can!

If you install fuzzy finder fzf , you can use interactive mode zi (or ji if you set up the alias) to easily search in paths in case of similar result paths for the same input. Love it.

  • 🪟 winget install -e — id ajeetdsouza.zoxide + winget install -e — id junegunn.fzf
# add into Powershell profile file
Invoke-Expression (& { (zoxide init powershell --cmd j | Out-String) })
  • 🍎/🐧 brew install zoxide fzf
# .zshrc
eval "$(zoxide init --cmd j zsh)"

4.3 Fast Node Manager

Remember the time savings I mentioned in the previous section? Here is some more for Node.js developers! I am pretty sure that most of us know about Node Version Manager aka nvm. It serves to switch between various versions of Node.js without much overhead, except for it not making the switch automatically when you open a project directory. And as I mentioned above, I switch between directories. A lot.

Fast Node Manager fnm registers your .nvmrc files by default so when you enter a folder, it switches to the correct version of Node.js. And if you use the auto-switch on change dir, you can stop thinking about Node.js versions for most of the time. By the way, just by switching from autojump and zsh-scripted nvm autoswitch to zoxide+fnm, I am finally no longer facing VS Code warnings about slow terminal session init. What more can you ask for? Install steps, right?

  • 🪟 winget install -e — id Schniz.fnm
# add into Powershell profile file
fnm env --use-on-cd | Out-String | Invoke-Expression
  • 🍎 / 🐧 brew install fnm
# .zshrc
eval "$(fnm env --use-on-cd)"

As for Volta — yes, it is a great tool which even switches to the right version after pulling the updated package.json from remote, which FNM cannot do, but it does not provide a prebuilt binary for Asahi Linux. I heard there are people who do not like that. Like me. So the “official reason” or made-up excuse for my recommendation of FNM is, of course, that our company is already invested in .nvmrc files.

4.4 Fastfetch

Life is not only about productivity. Sometimes we need some things just for the sake of liking them. Like this system overview list in your terminal:

“Hey, that is Neofetch!”. Nope, Fastfetch. Neofetch was recently archived, so Fastfetch is now the maintained way to get cool looking overviews of your setup.

  • 🪟 winget install fastfetch or releases page
  • 🍎 / 🐧 brew install fastfetch

5. Is there more?

For sure there is. I could recommend you tig for easy work with git logs and changes in commits, but that is not easily installable cross-platform. There are apps in the Modern Unix list. And certainly there are some new fresh applications I have never heard of yet. Or I could tell you that you can use export EDITOR=”code -w -n” to use VS Code for editing commits instead of that “infamous” Vim.

But at least I hope, you learned a thing or two about the possibilities and in case you knew them all already, you at least enjoyed this article! Feel free to add comments and here are the promised Powershell profile and ZSH files.

--

--