This powershell function allows you to bookmark a path and then effortlessly return to it at a later time.
Imagine having a short list of bookmarks available in your CLI. You have one for your current project, one for your other current project, one for your Neovim setup, one for this thing you jave to do this week and never have to touch again, and etc. Imagine being able to jump between them with one simple command.
Now imagine you only have 10 bookmark slots, so you have to be judicious as to what you bookmark, and how you maintain the list, so that it continues being useful.
Symlinks tend to be permanent. They are easy to set up, but equally easy to never delete, so you end up with a lot of clutter in your home directory. A limited list of 10 bookmarks forces you to actively prune it, and make decisions about to what should be on it, based on how often you use it.
To use j
, first browse to a desired location, then run:
j set 1
This will set the current path as bookmark 1
.
You can then run:
j 1
This will jump to that bookmark. Alternatively you can run the command without any arguments:
j
This will print out a list and let you choose a bookmark to jump to.
You can overwrite any bokmark by simply setting it again. Note that bookmarks must be numerical.
To delete an existing bookmark run:
j delete 1
This will delete bookmark 1
.
The j
script uses the following:
To install the dependencies run:
winget install skate
winget install gum
To install the dependencies run:
brew install skate
brew install gum
Under the hood the script saves your bookmarks in a Skate db named @j
. If something goes wrong you can always delete bookmarks from there manually. You can also use the sync functionality built into Skate to have the bookmarks distributed across multiple machines (though that may not be as useful as it may seem).
Copy and paste the function into your $PROFILE
file our source it there.
Put jmp
file somewhere in your path, then in your .zshrc
file add the folliwing:
function j() {
answer=$(jmp $@)
if [ -n "$answer" ]; cd $answer
}