If You are a Terminal User, You MUST try this tool!

Mammad Yahyayev - Aug 21 - - Dev Community

Hello folks. In today’s article, I want to share the tool that I can’t survive a day without it. Let’s not waste our time and dive deep into the topic.

Introduction

I bet as a terminal user you’ve dealing with the situation that you open multiple terminal to start your applications. If those application located in different places, then you have to manually change the current working directory to project’s directory.

Instead of manually going through each directory, you can type the name of the last directory on your terminal, and boom!. Now current working directory is your project’s directory.

The tool name is zoxide.

It remembers which directories you use most frequently, so you can “jump” to them in just a few keystrokes. zoxide works on all major shells.

zoxide written in Rust language.

Installation

zoxide is supported on Windows/Mac OS/Linux and there are multiple ways to install zoxide into your favorite terminal.

You can find all installations options in official GitHub repository.

Zoxide Use Cases

If you fully installed zoxide and type z in your terminal, then you will see nothing in your terminal window.

Move to Directories with One COMMAND

Imagine you want to move to following directory.

~/Desktop/learning/projects/python/data-science/pandas
Enter fullscreen mode Exit fullscreen mode

Changing current working directory to above path will usually take more than 5 seconds, it can take more if you half remembered the path or there are other directories.

With zoxide, you can move to pandas directory in just blink of an eye.

~/Desktop$ z pandas
~/Desktop/learning/projects/python/data-science/pandas$
Enter fullscreen mode Exit fullscreen mode

Important note here! If this is your first time to move pandas directory after zoxide installation, it might not work. Therefore you have to manually change directory once to make zoxide remember the path.

Same Directory Name in Different Case

zoxide tool is case insensitive in certain situations. For instance, you have directory called Desktop and you type Desktop or desktop both will redirect to the same directory.

However, if you have directories called Test and test, in this case, if you type Test, you will end up in Test directory.

Use Few Letters of Directory to Change Current Working Directory

Imagine this scenario: You are working in a microservice application that has similar naming pattern. For example,

~/Desktop/projects/microservice/banking/payment-ms
~/Desktop/projects/microservice/banking/user-ms
~/Desktop/projects/microservice/banking/notification-ms
~/Desktop/projects/microservice/banking/card-ms
Enter fullscreen mode Exit fullscreen mode

In above case, you don’t need to write the directory name as a whole. Just type pay or payment to move payment-ms directory, same is true for other directories as well.

How to Add Directory Manually to Zoxide

You can add directories manually to zoxide. Execute following command on your terminal.

~/Desktop$ zoxide add <directory-path>
Enter fullscreen mode Exit fullscreen mode

However, I don’t recommend this. Just use cd command once, and next time zoxide will remember the path.

More Operations

You can do more operations with zoxide:

  • limiting number of directory path in the zoxide database.
  • define aging algorithm to delete path from database after certain time.
  • exclude certain directories from zoxide database.

You can do more but above use cases is more than enough for everybody.

Third Party Integrations

You can install third party integrations to make zoxide more powerful.

References

Conclusion

This is the end of the article. Thanks for reading. If you find this article useful, follow for more.

I am open for any suggestions, you can reach me via LinkedIn.

See you soon in upcoming articles.

. . . . . . . . . . . . .