Skip to content

Instantly share code, notes, and snippets.

Last active Oct 21, 2021
What would you like to do?
open git host url for current repository with browser in powershell
function Open-GitWeb {
$r = git remote -v | Select-String -Pattern "(https:\/\/|git@)(?<git>.*)\.git"
if ($r.Matches.Length -gt 0) {
$t = "https://" + ($r.Matches[0].Groups |
Where-Object {$_.Name -eq "git"}).Value.Replace(":", "/")
Write-Host "gh: openning ",$t,"..." -ForegroundColor "green"
Start-Process $t
Write-Host "gh: not a git repository or origin not set correctly." -ForegroundColor "red"
Set-Alias gh Open-GitWeb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment