Zoxide: The Versatile Directory Navigation Tool

Zoxide is a modern, smarter alternative to the traditional cd command which is designed to streamline your directory navigation.
Zoxide: The Versatile Directory Navigation Tool

Introduction

Navigating the command line efficiently is crucial for maintaining productivity, especially in a home lab environment or when managing complex workflows. Zoxide is a modern, smarter alternative to the traditional cd command which is designed to streamline your directory navigation. It learns your frequently accessed paths and allows you to jump between directories with minimal keystrokes, significantly boosting your command-line efficiency.

In this blog post, I will guide you through the installation and usage of zoxide, focusing on Ubuntu but also applicable to other Linux distributions, as well as Windows and macOS. Whether you're a seasoned sysadmin or a home lab enthusiast, mastering zoxide can enhance your workflows and save you valuable time.

Prerequisites

  • Have an up-to-date system.
  • Appropriate permissions, though it should run normally as the user you are logged into.
  • Have winget or Chocolatey installed for WIndows.
  • Have Homebrew installed on MacOS.

Windows

Install

The easiest way to install this is through winget , however, there is a chocolatey package available as well.

Winget

winget install ajeetdsouza.zoxide

Chocolatey

choco install zoxide

Add to PowerShell

You will need to modify the PowerShell Profile. If you have already created a PowerShell Profile, then you can skip to the next step.

New-Item -Path $PROFILE -Type File -Force

After the profile is created, open up the profile using this command:

notepad $PROFILE

Add the following in the notepad, save then exit:

Invoke-Expression (& { (zoxide init powershell | Out-String) })

Reload PowerShell

Use the following command to reload the PowerShell profile:

. $PROFILE

MacOS

Install

For MacOS, you can use Homebrew to install this:

brew install zoxide

Add to you .zshrc

nano ~/.zshrc
# zoxide
eval "$(zoxide init zsh)"

Use Control + O to save and Control + X to exit. Restart your console by typing source .zshrc.

Linux

Install

The recommended way is to use the script, this is pulled from the GitHub repo, so you should go there for the latest install script.

curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh

Add to your .bashrc

This is to add to your .bashrc, if you are using zsh instead of bash then substitute as necessary.

nano ~/.bashrc
# zoxide
export PATH="$HOME/.local/bin:$PATH"
eval "$(zoxide init bash)"

Use Control + O to save and Control + X to exit. Restart your console by typing source .bashrc.

Getting Started

Snipping this from the GitHub page, zoxide works exactly like cd does, but it learns where your directories and files are for easier frequent access.

z foo              # cd into highest ranked directory matching foo
z foo bar          # cd into highest ranked directory matching foo and bar
z foo /            # cd into a subdirectory starting with foo

z ~/foo            # z also works like a regular cd command
z foo/             # cd into relative path
z ..               # cd one level up
z -                # cd into previous directory

zi foo             # cd with interactive selection (using fzf)

z foo<SPACE><TAB>  # show interactive completions (zoxide v0.8.0+, bash 4.4+/fish/zsh only)

After a while, as you use this in place of cd if you type z storage events it should navigate you to ~/Storage/Pictures/Event. This is just an example of course. Capitalization doesn't matter and the more you use it the easier it is to navigate.

Conclusion

Zoxide offers a powerful enhancement to your command-line experience, making directory navigation faster and more intuitive. This can be beneficial in either a home lab or enterprise environment. Throughout this guide, we've explored the installation and usage of zoxide on Ubuntu, Windows via winget and chocolatey, and macOS with brew.

By integrating zoxide into your workflows, whether through basic commands or more advanced features, you can significantly boost your productivity. Given the capability of using it with PowerShell on Windows further extends its versatility. Zoxide brings efficiency and transforms the way you manage directories in your daily command-line tasks.


Full Disclosure

Most of this article is comprised of facts and opinions. The featured background image was created by andyoneru and is available on Unsplash. I added a blur and a gradient overlay with some text. The following images have been pulled or screenshotted from the respective websites/applications. I do not own this content.

Subscribe to Hi! I'm Harley newsletter and stay updated.

Don't miss anything. Get all the latest posts delivered straight to your inbox. It's free!
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!