Becoming a power user - Episode 2: zee my shell

Published

February 9, 2025

In this second instalment of the “Becoming a power user” series, I’ll cover my switch from being a casual terminal (bash) user to a slightly less casual user of zsh, Oh My Zsh, and the plugins that come with both.

Setting the stage: my history with the command line

I’ve been working with the Linux command line for quite a few years now, starting during my bachelor’s mostly out of curiosity and to feel like I was a haxor.

> Pictured: hackerman me during my bachelor’s, or what I thought I’d become by > using Linux.

Overall, I’ve always preferred Linux to Windows: the syntax feels “saner”, and I’ve had fewer issues getting development environments to work on Linux than on Windows. This does not mean, however, that I used the command line beyond the incidental cp, or ls. When I was feeling brave, I’d update my packages with sudo apt-get update.

I started getting in the weeds a bit more during my PhD, when I had to set up my laptop to run code remotely. Some shenanigans ensued, but still not a lot of interest on my part to “get better” at it.

In the end, it took starting a postdoc at Inria for me to finally deal with Linux in any meaningful way. I spent most of my time developing on the computing cluster, accessing it remotely through SSH. This also involved managing my home folder, a lot of du, and juggling environments between the (slow) shared disk and the (fast, but small) home folder.

Besides reminiscing once again on what has been, I’m going to discuss how I switched from bash to zsh, and why you might want to do that.

Why zsh?

To be completely honest, I’m not sure. I was somewhat curious to try out a different shell, and I probably spotted a post on LinkedIn that inspired me to try an alternative.

I must admit that “plain zsh” doesn’t feel much different from bash — though I can’t say I spent much time with it, since installing Oh My Zsh coincided with when I started using the shell for real.

Why Oh my zsh?

First off, what is Oh my zsh?

Shamelessly pasting from the GitHub repo: > Oh My Zsh is an open source, community-driven framework for managing your zsh configuration. > Sounds boring. Let’s try again. > Oh My Zsh will not make you a 10x developer…but you may feel like one. > Once installed, your terminal shell will become the talk of the town or your money back! With each keystroke in your command prompt, you’ll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, “that is amazing! are you some sort of genius?”

Yeah, I really wanted to live that hackerman fantasy from my bachelor’s.

I’ll let you check the installation instructions in the repository. Whatever command you use, the result will be a new .zshrc configuration file that includes goodies prepared by the zsh community (your old .zshrc will be saved as .zsh.pre-oh-my-zsh, so custom commands won’t get lost).

Then it’s time to edit the .zshrc file, which can be done with vim .zshrc. (Of course I’m using Vim now – see the previous episode: linux-tools-part1.qmd.)

My .zshrc config

First off: my theme. I’m using powerlevel10k (repo). Installing the theme runs a wizard that lets you customize options like having the prompt on a new line rather than on the same line as the cwd. I like that because it gives a full row of space even when the folder path is very long.

Additionally, the theme tells me which python environment I’m in and the status of the git repo in the folder, including the current folder: as you can imagine, that’s particularly useful when I’m working on some kind of repo.

On the note of tracking files with VCS, one setting I changed from the default was this:

DISABLE_UNTRACKED_FILES_DIRTY="true"

Doing this ignores tracking dirty files, which was helpful for some repositories.

zsh plugins

Plugins are community-made improvements that add functionality to the zsh configuration. There are hundreds to choose from, but I’d recommend keeping the number relatively low – too many plugins can noticeably slow startup time.

These are the plugins I am using, some more, some less:

plugins=(git virtualenv colored-man-pages python zsh-navigation-tools zsh-syntax-highlighting zsh-autosuggestions)

zsh-navigation-tools significantly improves backward search, which I use a lot: many commands I run are small variations of previous ones. Being able to navigate history quickly saves time and keystrokes, and those savings pile up.

zsh-autosuggestions is similar in the sense that it saves keystrokes, but does so by suggesting directly commands that I am likely to use.

The virtualenv plugin lets me know which python environment I am using in the current shell. This is quite useful for me because I tend to switch between environments frequently to test different things.

The git plugin adds many git-related commands, most of which I barely use.

Aliases, so many aliases

Speaking of aliases, I’ve set up quite a few that save keystrokes for my most used commands.

Some are simple shortcuts that let me navigate to my most-visited folders, like the main skrub repository.

alias cds="cd ~/Projects/work/skrub"
alias cdp="cd ~/Projects/"

Others replace more complex commands:

alias dc="pixi run -e dev build-doc-quick"
alias pd="pixi shell -e dev"
alias scratch="source ~/activate_scratch.sh"
alias ta="~/activate_tmux.sh"

dc and pd are pixi commands I type frequently when working in the main skrub directory (cds). scratch activates my scratch environment, which I use to test code in a “clean” scenario. Finally, ta calls a script that activates my tmux session with a specific configuration (that’s for the next episode).

Conclusions

Switching to zsh was another pretty big leap in efficiency at work and at home. While some of the omz plugins may be hit or miss, navigation with zsh is so much better than what I had access to with bash that it’s enough for me to justify the switch.

In later posts, I’ll go over my tmux setup, and some other tools I have been using for developing, both at work and for my personal projects.