A simple bookmark system for powershell to set shortcuts to quickly change directories while using the prompt.
Find a file
2024-06-20 17:53:59 -05:00
Bookmarks.ps1 Initial commit 2023-04-19 22:11:53 -05:00
bookmarks.sh Add linux style bookmarks.sh 2024-06-20 17:41:58 -05:00
README.md Add linux style bookmarks.sh 2024-06-20 17:53:59 -05:00

Bookmarks for PowerShell

Bookmarks in PowerShell Blog post

I work in the terminal quite a bit, and needed a quick way to change directories between projects. I started this based off a similar project in bash called lazy-cd. This works similarly as it stores the bookmarks you add to a file, and if the bookmark is found, the terminal location will be set accordingly.

Functions

  • Check-Bookmark - Initializing function to create bookmark file if needed
  • View-Bookmark - List all the bookmarks that have been added to the library
  • Add-Bookmark <name> - Adds the bookmark using the <name> and the current location you are in
  • Delete-Bookmark <name> - Remove the specified bookmark line based on the <name>
  • Goto-Bookmark <name> - If the bookmark <name> exists in the bookmark file, the terminal will Set-Location to the path defined.

Aliases

Alias Function
bm Goto-Bookmark
bma Add-Bookmark
bmd Delete-Bookmark
bmv View-Bookmark

Usage

Download the the bookmark.ps1 file and dot source it to your Microsoft.PowerShell_profile.ps1.

. "path\to\bookmarks.ps1"

PS C:> bmv
You have 4 Bookmarks

Bookmark      Path
--------      ----
home          C:\Users\username
website       C:\git\cjerrington.github.io
snippets      C:\git\snippets
root          C:\

Bookmarks for Bash

Bookmarks in Bash Blog post

Recreation of the PowerShell version, I just work a lot in Linux as well and wanted to recreate the same workflow.

Functions

Since the PowerShell method sets aliases, and those are easier to type, I stuck with the same alias names for the linux functions.

  • bmv - List all the bookmarks that have been added to the library
  • bma <name> - Adds the bookmark using the <name> and the current location you are in
  • bmd <name> - Remove the specified bookmark line based on the <name>
  • bm <name> - If the bookmark <name> exists in the bookmark file, the terminal will Set-Location to the path defined.

Usage

Download the the bookmarks.sh file and dot source it to your ~/.bashrc or other profile config file.

source ~/.local/bin/bookmarks.sh

$ bmv
Bookmark Name  Bookmark Path
website        /home/clayton/git/cjerrington.github.io
home           /home/clayton
downloads      /home/clayton/Downloads
git            /home/clayton/git