til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Use zoxide

An alternative to cd and z do not be confused that zoxide also often is referred to as z but it is a different tool.

zoxide is a command-line tool that helps you navigate your filesystem more efficiently by keeping track of the directories you visit and allowing you to quickly jump to them using a simple syntax - fast travel for directories.

You can specify file patterns to ignore using an environment variable:

export _ZO_EXCLUDE_PATHS=".git"

You can exclude directories using another variable:

export _ZO_EXCLUDE_DIRS="/tmp:/var:/node_modules"

And you can specify a custom database location:

export _ZO_DATA_DIR="$HOME/.local/share/zoxide"

This can be convenient as the default on macOS is: $HOME/Library/Application Support/zoxide

Flushing the database

Flush the database can be done by deleting it:

rm $HOME/Library/Application Support/zoxide/db.zo`

Adding the current directory

zoxide add $(pwd)

Shifting the weights

I ran into a problem where two repositories was quite close in named, so I kept ending up in the the wrong one.

One had a weight of 50+ the other 14.

I found out that the following hack can tip the weights:

cd into the directory and run.

for i in {1..40}; do zoxide add $(pwd); done

And now the weights are shifted as can be observed using zi

Resources and References

  • GitHub repository - The official repository for zoxide, where you can find the source code, documentation, and installation instructions.
  • zoxide.org/ - An independent, community-driven documentation project and is not affiliated with, endorsed by, or connected to Ajeet D’Souza or the official Zoxide project._
  • DeepWiki: zoxide - A comprehensive guide to using zoxide, including installation, configuration, and usage tips.