Software Design Enthusiast And Engineer

Use 'git-open' as a cross platform PowerShell command

2 min read
Status: Completed Read year: 2025

TLDR;

I created a PowerShell module that allows you to open git repos from your terminal. Check out the readme for more details.


On my Mac, it's surprising how much I use the git-open command while developing.

Lately, I've been immersed in the .NET world and with that, I've switch from using zsh as my primary shell, to PowerShell ("PS"). It's been great so far with the few exceptions to get my PS $PROFILE setup properly. Oh-my-zsh provides many conveniences that I've realized I've taken for granted for years now. After sticking with it though, my PS profile is dialed in pretty well and I've really started to enjoy the many (many!) benefits that PowerShell has to offer.

With that, I have to start building something when I'm wanting to scratch an itch.

Enter: Open-GitRepo

This is a PowerShell module I threw together today that allows one to open their repo (in the browser) from their terminal. I focused on ensuring this runs in cross platform scenarios (I wrote the code while on my Mac too).

Also, unlike it's Unix-based predecessor, this module works for GitHub and Bitbucket repos. I can see why this other library chose not to do the Bitbucket side of the logic - Bitbucket's urls for their repositories follow an overly-complicated convention.

As an example, here's what the 'default branch's URL might look like:

https://bitbucket.org/bbworkspace/customrepo/src/main

Whereas, if it's not the default branch, things go off the rails pretty quick. This is what a secondary branch URL looks like:
https://bitbucket.org/mybbworkspace/mybbrepo/src/acc31fe8745678bc987b123d87d7ac72fec220e52/?at=hotfix%2Fmy-test-branch (I know...)

This meant I had to get a bit fancy when writing this Open-GitRepo PS module whenever the logic detects a Bitbucket remote URL for the repository. It's all working flawlessly, tested (of course), and there's a couple other features I haven't mentioned in this post. Be sure to check it out. Please do let me know if you end up using it and how your experience goes.

Check out the readme for more details.


I welcome your feedback:

Reach out on any of the following...

Reddit:
https://www.reddit.com/r/PowerShell/comments/1kw56np/gitopen_for_powershell_opengitrepo/

X: