A lightweight helper to create and use directory “bookmarks” via bookmark and its alias bm.
- Copy the Bash
bookmarkfunction andalias bm=bookmarkinto~/.bashrc. - Reload your shell:
source ~/.bashrc- Copy the zsh
bookmarkfunction andalias bm='bookmark'into~/.zshrc. - Reload your shell:
source ~/.zshrcIf you use Bash on macOS, follow the Linux (Bash) instructions instead.
- Open your PowerShell profile:
notepad $PROFILE- Paste the PowerShell
bookmarkfunction andSet-Alias bm bookmarkinto that file, then save. - Reload the profile:
. $PROFILE- Save any directory as a bookmark.
- Jump to a directory using its bookmark name.
- List all bookmark names.
- Remove bookmarks.
- Rejects duplicate names and names containing spaces.
bookmark --create . # current directory
bookmark --create ./path/to/dir/ # specific directory
bookmark -c ../ # short formYou will be prompted:
[Bookmark Title]: sample_title
[SUCCESS] - bookmark sample_title has been created
Errors:
-
Existing title:
[ERROR] - bookmark sample_title already exists -
Title with spaces:
[ERROR] - bookmark sample title has spaces
bookmark --jump sample_title
bm -j sample_titlebookmark ls
bm ls(Printed one title per line.)
bookmark rm sample_title
bm rm sample_titleOutput:
[SUCCESS] - sample_title removed
# or
[ERROR] - sample_title doesn't exist
- Bookmark titles must not contain spaces.
- Bookmarks are stored in
~/.dir_bookmarks. bmis a shorthand alias forbookmark.