This post was originally published on Siv Scripts
Even though my development folders are well organized, I still have to feel my way around the filesystem when I'm looking for a project directory. It's like trying to find a lightswitch in a dark room: a cd
here, an ls
there, maybe a find
when I'm stuck.
I always get to where I want to go, but not without some frustration along the way. Plus, all the seconds spent navigating directories starts to add up.
Wait a minute. I use bookmarks in my browser, so why am I not using them in my shell?
A quick Google search led me to Bashmarks. Absolute game changer. I can move around the filesystem with ease.
In this Quick Hit, we will explore Bashmarks, walk through the installation process, and get a feel of the most commonly used commands.
Bashmarks
Bashmarks is a [bash] shell script that allows you to save and jump to commonly used directories
It supports tab completion (!!!) and has a very simple interface with only 5 commands to memorize.
Use another shell? Not a problem. There are ports of bashmarks for fish and zsh.
Installation
Download the files into a temporary directory and install using GNU make:
mkdir temp && cd temp
git clone git://github.com/huyng/bashmarks.git
cd bashmarks
make install
echo "source ~/.local/bin/bashmarks.sh" >> ~/.bash_profile
source ~/.bash_profile
And we're good to go!
Commands
s <bookmark_name> - Saves the current directory as "bookmark_name"
g <bookmark_name> - Goes (cd) to the directory associated with "bookmark_name"
p <bookmark_name> - Prints the directory associated with "bookmark_name"
d <bookmark_name> - Deletes the bookmark
l - Lists all available bookmarks
We can save bookmarks using the s [bookmark_name]
command:
Navigate to project directory using g [bookmark_name]
:
Conclusion
Bashmarks is a tool that increases developer productivity.
Do you have an interesting terminal workflow or trick to share? Please comment below!
Top comments (8)
I recommend to use "fasd" instead. It removes the whole need to manually enter bookmarks and automatically remembers every folder your interacted. So you just need to "cd temp" once and since then, just type "z temp" to go there.
I wrote about it here: hackernoon.com/macbook-my-command-...
I would also like to recommend a tool called
wd
. It basically does the same thing but for me the way it operates it's a little bit explicit. For example the adding of new path iswd add
and it adds the current working directory.github.com/mfaerevaag/wd/blob/mast...
Interesting - I always accomplished this by just adding a bunch of aliases to my bash profile (
cdw
for example justcd
's into my workspace. This seems like a cleaner way to handle things when you've got a bunch of places to go!I know this is old but for anyone stumbling across this and they are using
zsh
then what you really want is to usehash
to modify the command hash table so that you can then get an even shorter syntax and not need the extra aliases. E.g. if you run this:you can then do:
or even:
or even even:
to change directory. You can also then substitute in
~o
anywhere where you would usually place a path such asls ~0
.z is also good. It keeps a list of your statistically frequent and recent cd commands. If you have a lot of directories with similar names, however, you'll probably have better luck with this approach.
The one thing I take issue with in this approach is the use of four single-letter shortcuts. For me, g is for git, and l is for ls -la.
It's weird for me to take issue with this approach this way, since I do use the z macro.
I have installed it and it looks really helpful. But, can anyone tell me how to turn off sort of command auto completion on terminal, like when I type "l" it always treat the command as "ls", so I can't list all my bookmarks.
interesting~
I have installed this