Siv Scripts

Solving Problems Using Code

Sat 07 October 2017

Terminal Tricks: Directory Bookmarks

Posted by Aly Sivji in Quick Hits   

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.

Feel a bit like Dr. Who.
Teleport like a boss

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:
Create bashmark

List all bashmarks with l:
List bashmarks

Navigate to project directory using g [bookmark_name]:
Jump to bashmark


Conclusion

Bashmarks is a tool that increases developer productivity.

Do you have an interesting terminal workflow or trick to share? Please comment below!


 
    
 
 

Comments