zoxide has forever improved the way I navigate in the terminal.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
CD or change directory is undoubtedly one of my most used commands having used it for as long as I've been working in the terminal I've never felt like anything was missing or anything more was needed so when I came across zo oide which describes itself as the smarter CD command I was intrigued what more could I possibly need well as it turns out quite a lot after using it for about a week in my system I can confidently say that it's improved the way I work in the terminal for the better the command allows me to navigate around my projects and directories at a much greater speed and does so whilst saving me brain Cycles in the process all of this translates to saving me time keeping me focused and making me more productive let me show you how it works the first thing you'll need to do is install Z oxide onto your system to do so takes a couple of steps the first one is to download and install the zo oxide binary onto your operating system you can do this with either cargo or your operating systems package manager as I'm using Arch by the way I'll install it using Pac-Man once installed the next step is to set it up on your shell the documentation lists instructions for all of the major ones such as bash zshell fish and even posx in my case I'm using zshell so all I need to do is add the following line to the end of my zshell RC and I can do this using the following command now if I open up a new terminal I have the Z command available to me so what can it do well nothing special yet in order to unlock Ze oxide's true potential we need to first train it by navigating around our file system like we would do normally but using the Z command instead to do so is pretty much the same as using CD if we want to change into another directory we just use the Z command and pass in the directory's path which can be either relative or absolute if we want to return to our home directory then we can just use the Z command by itself and if we want to return to the previous directory we can do so by passing in a dash instead of a path so far all of this is pretty much in parity with the way that CD works as I said none of this is special however after you've used Z oxide for a little bit that's when things start to become interesting let's say I want to make some changes to my neovim config in order to do so I need to navigate to the directory that contains my neovim configuration files this is all the way in my home. config envm /l/ custom directory which is nested pretty deep in order to get there with CD I have to use the full path every time which can be rather tedious the only way to speed this up are by using either my Zell history or defining a custom Alias for any directories that I use frequently with Z oxide however if I want to get there quickly all I have to do is type in Z envm custom and it takes me straight there yeah that's pretty awesome so how does it work well as I've been navigating around Z oxide has been working in the background adding weights to my most frequently visited paths this means that if I want to jump into a directory that I've already visited with Z oxide I can do so using path fragments rather than specifying the entire thing Z oxide will then use its internal matching algorithm to determine which path to use this algorithm has four main properties the first is that the search term is case in sensitive meaning that you can write your terms in lowercase and they'll still match to any mixed or uppercase path components secondly all of the terms that you provide must be contained within the path in the same order for example whilst enm lower matches lower enm will not this is because there is no path entry that contains those terms in that order the third matching rule states that the last component of the last keyword must match the last component of the path for example dreams recorder will match the following path this is because the path and the term both end with recorder however if I use the term dreams tools then that won't match this is because none of my path entries end with tools as their last component and the final part of the algorithm is that all matches are returned in descending order of their weights this means that any conflicts are resolved with the path containing the highest weight being chosen in my case I have two paths that end in config if I use the Z config command then it will choose the path with the highest weight this weight value is known as the frency which is an amalgamation of frequency and recency and these two properties Define the value of the weight or score the first is the frequency which is the number of times that the directory has been visited each time it is then its rank goes up by one point the second property is the recency which is how long ago the directory was last visited the documentation goes into detail about how this works each score has a modifier based on the amount of time since it was last access if the last access time was within 1 hour then the score is multiplied by four within the last day it's multiplied by two if it's within the last week the score is divided by two otherwise it's divided by four all of this makes Z oxide incredibly Dynamic especially compared to Alternatives such as creating aliases which are typically static and require you to have to create and manage them manually in addition to this because Z oxide removes the need for me to type uppercase characters and symbols My Fingers Never travel far from the home row which increases my typing speed for navigation and because I no longer need to remember the full path it's much easier on my brain to remember where I need to go even with this I can still sometimes forget when that happens I find that looking at a list helps to give my brain a friendly nudge fortunately that's where another feature of Z oxide comes in handy in order to enable this feature we need to install another package on our system this is fzf fzf is a fuzzy finder tool for the terminal if I install it using Pac-Man and then run it you can see how it works it lists all of the files in my directory and allows me to search for them in a fuzzy way pretty cool but by itself it's not that useful however when combined with Z oxide it becomes incredible if if I type in the zi command which stands for Z oxide interactive we're now shown an FCF window containing a list of all the directories we visited using Z oxide in descending order of their score I can scroll through this list using contrl p and crl N or I can just search for a directory with fuzzy finding by typing out the name by doing so I can then select the entry I want and I'll be navigated to it as well as the zi command you can also bring up an interactive menu whilst you're typing out your terms to do so start typing out the prefix of the directory you wish to change to then when you want to bring up the menu press the space key followed by pressing the Tab Key which brings up another fuzzy finder window rather than showing all of our paths like the zi command does this will only show a subset of our entries that match the given prefix both of these features are really useful for those times you need a visual clue to give you a nudge in the right direction however as you can imagine the list of entries in the Ze oxide database can start to grow rather large fortunately Z oxide does age these off once once the total score gets to above 10,000 by default this then triggers a rebalancing event causing all of the scores in the database to be recalculated afterwards any scores that fall below a certain threshold are then removed from the database in addition to this Z oxide also provides a number of commands to perform crud operations on the entries that zo oxide manages the first of these is the add command which will allow you to either add a directory or increment its rank without having to travel to it next is the query command which allows you to search for a directory in the database you can also display the score of any results using the- S flag or list all of the entries by using- L the remove command allows you to delete any directories from the database which is Handy if Z oxide resolves to any unwanted paths and finally the edit command brings up an interactive window which will allow you to modify entries in the database through this menu you can either increment or decrement the rank of an entry or remove an entry entirely all of this can be done using the keys listed at the top of the menu so at this point I'm pretty convinced C oxide definitely improves my workflow however there's a catch as I mentioned at the start CD is one of my most used commands therefore undoing that muscle memory is going to be very difficult not only that but if I have to change to using the Z command for navigation anytime I move or SSH onto another machine that doesn't have Z oxide installed I'll need to adjust my muscle memory again this results in the SE oxide command becoming a crutch to prevent this from happening I can rebind the CD command to use Z oxide instead the easiest way to do this is to just use a shell Alias however I prefer to take a different approach the Z oxide init command allows us to pass in an option called CMD which changes the prefix of both the Z and Zi commands we can add this to the init command inside of our shell RC file here we'll add the-- CMD option specifying the CD command once that's added we can then save and close our file and open up a new terminal to test it out now I no longer have the Z command available however if I run which on the CD command you can see that it's Alias to the Z oxide Z command instead now I can use CD as I would do normally whilst also taking advantage of the features of Z oxide additionally by aliasing this way we also now have access to interactive mode using CDI one thing to make note of however is this doesn't work for New Shell or any posic space shells however for Zell bash and fish this works absolutely fine for me I'm pretty happy with this setup because I live in the terminal so much using zo oxide for my CD command has improved my workflow considerably so much so that I don't think I could ever go back to just the vanilla CD command I'm interested to know your thoughts however are you planning on giving Ze oxide a go following this video or perhaps you were using it already let me know in the comments down below otherwise I want to give a big thank you for watching and I'll see you on the next one
Info
Channel: Dreams of Autonomy
Views: 424,875
Rating: undefined out of 5
Keywords:
Id: aghxkpyRVDY
Channel Id: undefined
Length: 9min 52sec (592 seconds)
Published: Wed Feb 14 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.