Bookmarks in PowerShell

20 Apr, 2023

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.

Making this work, I knew a few functions were needed and was interested in some better function management. I learned a lot on processes, procedures, function arguments, and some simple regex to help search and find the bookmark item for each function and cleanly execute the task at hand.

Functions

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:\

Downloading and contributing

You can view the source code and help improve the process if needed as well. Check out the Bookmark repo on Codeberg. Oh, and to be exciting, it's less than 100 lines of code!

Thanks to a few

I was chatting on mastodon the other day and got some great advice as well from a few folks on how to make this possible.

Thanks to the following for some inspiration!


I'm publishing this as part of 100 Days To Offload. You can join in yourself by visiting 100DaysToOffload.com.

Tags: automation, powershell, 100DaysToOffload

Webmentions

If there are replies, they will show below.

5 Likes 5 Reposts

6 Replies

Clayton Errington πŸ–₯️ Clayton Errington πŸ–₯️
Thought I’d keep some personal and open source projects out on the #codeberg community! 😁@RL_Dane @Codeberg @benjaminhollon @sassdawe @bjompen @furicle Codeberg
R. L. Dane R. L. Dane
@cjerringtonNIIIIICE! πŸ‘πŸΌπŸ‘πŸΌAlso, +1 for using @Codeberg 😁@benjaminhollon @sassdawe @bjompen @furicle
Benjamin Hollon Benjamin Hollon
@cjerrington @RL_Dane @Codeberg @sassdawe @bjompen @furicle Yessss good for you!
Benjamin Hollon Benjamin Hollon
@cjerrington @RL_Dane @sassdawe @bjompen @furicle Oh good, glad you got around to doing this!
Bjompen Bjompen
@cjerrington @benjaminhollon @RL_Dane @sassdawe @furicle wow! I love it! Will absolutely use it.
Joel Bennett Joel Bennett
@cjerrington nicely done. I'm not sure if I can bring myself to switch from zLocation (which just stores every folder you're in, and sorts them by how much work you do in them, and matches with wildcards), but I like it πŸ™‚


Found an issue? Edit on Github

← Back home