How to use the command bashmarks (with examples)
Bashmarks is a command-line utility designed to streamline navigation in the Linux or macOS terminal environment. It allows users to save directories as bookmarks and quickly jump to them using short, efficient commands. This tool is especially useful for developers, system administrators, or any users who frequently navigate deep directory structures. With bashmarks, you can save time and enhance productivity by reducing the need to type lengthy paths repeatedly.
Use case 1: List available bookmarks
Code:
l
Motivation:
As you navigate through your file system, you may have several directories bookmarked for quick access. Over time, it’s easy to forget the names of all these bookmarks. By listing all available bookmarks, you gain a clear overview of all saved directories, helping you choose the correct one for your current task.
Explanation:
The command l
is used without any additional arguments, making it straightforward and easy to use. It leverages bashmarks to display a list of all directories you have saved as bookmarks.
Example output:
project
work
archive
Use case 2: Save the current directory as “bookmark_name”
Code:
s bookmark_name
Motivation:
Suppose you arrive at a directory you access frequently and realize it would be beneficial to save its path for future convenience. By saving it as a bookmark, you avoid typing or navigating to this directory manually every time—greatly speeding up repetitive tasks.
Explanation:
s
is the command used to save the current directory.bookmark_name
is a placeholder for whatever memorable name you wish to assign to this directory. Ensure it’s unique and easy to remember since it’s the key to accessing the directory later.
Example output:
Assuming you’re in /home/user/projects
and you save it as my_project
:
Bookmark added: my_project
Use case 3: Go to a bookmarked directory
Code:
g bookmark_name
Motivation:
Jump quickly to any directory you’ve previously bookmarked without needing to remember its full path. This is highly efficient for frequent switches between multiple working directories, allowing you to maintain workflow momentum and reduce cognitive load.
Explanation:
g
is the command that triggers the action of going or navigating to a specific directory.bookmark_name
refers to the previously saved name of the directory you wish to access.
Example output:
If you have my_project
bookmarked, the terminal will navigate directly to /home/user/projects
:
cd: /home/user/projects
Use case 4: Print a bookmarked directory’s contents
Code:
p bookmark_name
Motivation:
If you need to review what files or folders exist in a bookmarked directory without actually navigating into it, this command serves your purpose. It allows you to quickly scan through contents, aiding in decision-making processes such as file edits or retrieval.
Explanation:
p
is the command used to print the contents of the bookmarked directory.bookmark_name
indicates the directory whose contents you wish to obtain.
Example output:
Consider my_project
as your bookmark:
README.md
main.py
utils/
docs/
Use case 5: Delete a bookmark
Code:
d bookmark_name
Motivation:
As projects conclude or file structures change, you might find certain bookmarks obsolete or cluttering your list. Deleting these bookmarks can help maintain an organized workspace, ensuring that your list of bookmarks remains relevant to your current needs.
Explanation:
d
is the command that deletes a bookmark.bookmark_name
specifies which bookmark should be removed.
Example output:
Removing the my_project
bookmark:
Bookmark deleted: my_project
Conclusion:
Bashmarks is an invaluable tool for anyone working in a terminal who frequently navigates between different directories. Its simple yet powerful functionality can dramatically enhance efficiency and reduce frustration associated with path navigation. Mastering bashmarks allows you to allocate more time to your tasks and less to managing your workflow environment.