Tools I like: Zoxide

Here’s a tool I use all the time without even thinking about. It’s called z or Zoxide

Often times I feel developers set out trying to keep paths and filenames in an at least manageable structure. I try to keep a consistent cousins/coworkers approach to organizing but occasionally and especially when working across multiple projects things can get out of hand.

Inevitably my top level Home directory starts to look a little like

$ tree -d -L 1
├── Android
├── AndroidStudioProjects
├── bot-thought-notes
├── Calibre Library
├── clients
├── Desktop
├── Documents
├── Downloads
├── its-free-real-estate
├── fedora-backup
├── go
├── Music
├── my-config-files
├── packages
├── Pictures
├── projects
├── Public
├── rpmbuild
├── secrets-to-the-universe
├── src
├── Templates
├── thoughtbot
├── tmp
└── Videos

23 directories
$ # I hid the hidden directories because the sheer quantity of ~/.scratch-* dirs I have kicking around is borderline shameful

Now where did I put that Go project? projects? src? go?

Some folks will crack open a file explorer or finder to look around and then cd where they want to be, I use z.

Z acts as a drop in replacement for cd with some extra features. My favorite is that z will remember paths that you’ve moved through and “jump” you to a new working directory.

Like this:

$ # z will keep track of this path
$ z /src/project/whatever/too_long/mixedCases?/wow-thats-a-choice/my-awesome-project
$ # now we can spare ourselves a history search / tab completes/ or a long typing session and just use z
$ z my-awesome-project
$ # Z comes with a built in switcher and the ability to scope junps
$ # meaning I can do this
$ z my-awesome-project node_modules
$ # and Z knows to only bring me to this node_modules dir and not the other 200 ones I have floating around

For me this comes in particular handy in a few places.

  • Building packages locally that end up (inevitably) being too many versions behind and jumping back and forth between them.
  • Jumping to make a quick tweak in my neovim config files and back!
  • Jumping to a project that I use for work but doesn’t live in the thoughtbot directory

There’s loads more you can do with it including editor

Try it out!