A command-line tool to bookmark directories and quickly navigate between them.
Author: Hasin Hayder
Repository: https://github.com/hasinhayder/bookomark.py
- Clone or download this repository
- Run the setup script:
./setup.sh
- Restart your terminal or run
source ~/.zshrc
- Start bookmarking:
bookmark
and navigating:goto
- Save current directory with a friendly name
- Remove bookmarks for current directory
- List all bookmarks in alphabetical order
- Navigate to bookmarked directories using
goto
function - Open bookmarked directories in Finder (macOS)
- Debug bookmarks file in VS Code
- Bulk operations (list all, flush all)
- Backup and restore bookmarks - Create timestamped backups and restore from them
- Duplicate prevention for both paths and names
- Automatic setup script for easy installation
Easy Setup (Recommended):
Run the setup script to automatically configure everything:
./setup.sh
This will:
- Add the
bookmark
alias to your shell configuration - Source the
goto_function.sh
to enable thegoto
command - Configure everything for immediate use
After setup, either restart your terminal or run:
source ~/.zshrc # or ~/.bashrc for bash users
Manual Setup (Advanced):
If you prefer manual installation, add these lines to your ~/.zshrc
(or ~/.bashrc
for bash):
# Directory Bookmark Manager
alias bookmark='python3 /path/to/bookmark.py'
source /path/to/goto_function.sh
After running ./setup.sh
, you can use these commands from anywhere:
Add a bookmark for current directory:
bookmark
You'll be prompted to enter a friendly name for the current directory.
Remove bookmark for current directory:
bookmark --remove
Navigate to bookmarks using the goto function:
goto
This will:
- Show all bookmarked directories with numbers
- Prompt you to select a number
- Change to the selected directory in your current shell session
List bookmarks and select one (for scripting):
bookmark --list
Get directory path for shell navigation:
goto
Open bookmark in Finder (macOS):
bookmark --open
Debug bookmarks file:
bookmark --debug
This opens the ~/.dir-bookmarks.txt
file in VS Code for manual editing or debugging.
Clear all bookmarks:
bookmark --flush
This permanently deletes all bookmarks from the file.
List all bookmarks with paths:
bookmark --listall
This displays all bookmarks with their full directory paths and a total count.
Create a backup of your bookmarks:
bookmark --backup
This creates a timestamped backup file: ~/.dir-bookmarks-backup-YYYYMMDD_HHMMSS.txt
Restore bookmarks from a backup:
bookmark --restore
This will:
- Show available backup files with timestamps and bookmark counts
- Prompt you to select which backup to restore
- Create a backup of your current bookmarks before restore
- Restore the selected backup file
# Open a bookmark in Finder
bookmark --open
# Shows:
# 1. docs
# 2. myapp
# Select: 1
# Outputs: /Users/username/Documents/Important
# Opens the directory in Finder
# Debug bookmarks file
bookmark --debug
# Opens ~/.dir-bookmarks.txt in VS Code
# Create backup of bookmarks
bookmark --backup
# Creates ~/.dir-bookmarks-backup-20250620_143025.txt
# Shows: Bookmarks backed up to: ~/.dir-bookmarks-backup-20250620_143025.txt
# Backed up 5 bookmark(s)
# Restore from backup
bookmark --restore
# Shows available backups:
# 1. 2025-06-20 14:30:25 (5 bookmarks)
# 2. 2025-06-19 10:15:30 (3 bookmarks)
# Select backup to restore (number): 1
# Creates backup of current bookmarks before restore
# Clear all bookmarks
bookmark --flush
# Removes all bookmarks permanently
# List all bookmarks with paths
bookmark --listall
# Shows:
# 1. docs -> /Users/username/Documents/Important
# 2. myapp -> /Users/username/Projects/MyApp
# Total: 2 bookmark(s)
bookmark
- Add current directory as bookmarkbookmark --remove
- Remove current directory's bookmarkbookmark --list
- List bookmarks and select one (outputs path)bookmark --open
- List bookmarks and open selected one in Finderbookmark --listall
- Display all bookmarks with their full pathsbookmark --debug
- Open bookmarks file in VS Code for editingbookmark --flush
- Clear all bookmarks permanentlybookmark --backup
- Create timestamped backup of bookmarksbookmark --restore
- Restore bookmarks from backup filegoto
- Navigate to bookmarked directory (shell function that changes current directory)
bookmark.py
- Main script with all bookmark management and navigation featuresgoto_function.sh
- Shell function for directory navigation (uses bookmark --go internally)setup.sh
- Automated setup script for easy installationtest.sh
- Test script to verify all functionality works~/.dir-bookmarks.txt
- Storage file for bookmarks (auto-created)
Bookmarks are stored in ~/.dir-bookmarks.txt
in the format:
friendly_name|/full/path/to/directory
# Navigate to your projects directory
cd ~/Projects/MyApp
bookmark
# Enter: "myapp"
# Navigate to another directory
cd ~/Documents/Important
bookmark
# Enter: "docs"
# Navigate using goto function
goto
# Shows:
# 1. docs
# 2. myapp
# Select: 2
# Changes to ~/Projects/MyApp
# Remove a bookmark
cd ~/Projects/MyApp
bookmark --remove
# Removes the "myapp" bookmark
# Get directory path for scripting
goto
# Shows:
# 1. docs
# Select: 1
# Outputs: /Users/username/Documents/Important
# List all bookmarks and get a path
bookmark --list
# Shows:
# 1. docs
# Select: 1
# Outputs: /Users/username/Documents/Important
# Open a bookmark in Finder
bookmark --open
# Shows:
# 1. docs
# Select: 1
# Outputs: /Users/username/Documents/Important
# Opens the directory in Finder
# Create backup before making changes
bookmark --backup
# Creates timestamped backup
# Restore from backup if needed
bookmark --restore
# Lists available backups and restores selected one
- Prevents duplicate directory bookmarks
- Warns about duplicate friendly names with option to overwrite
- Validates directory existence when navigating
- Handles file I/O errors gracefully
- Input validation for user selections
Author: Hasin Hayder
GitHub: https://github.com/hasinhayder/bookomark.py
This project is licensed under the MIT License - see the LICENSE file for details.
- ✅ Commercial use - Use in commercial projects
- ✅ Modification - Modify the source code
- ✅ Distribution - Distribute copies
- ✅ Private use - Use privately
- ✅ Patent use - Grant of patent rights from contributors
Copyright (c) 2025 Hasin Hayder