4

Terminal Tricks: Directory Bookmarks

 2 years ago
source link: https://alysivji.github.io/terminal-tricks-bashmarks.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Siv Scripts

Solving Problems Using Code

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!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK