oc
- Open commit details on Remoteop
- Open Remote Repository page
Created
September 30, 2025 03:07
-
-
Save iqfareez/4dd283af7d102086ed0dc72874d3d1c8 to your computer and use it in GitHub Desktop.
My PowerShell alias function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# or stands for openrepo | |
function or { | |
$url = git config --get remote.origin.url | |
# Convert SSH URL to HTTPS if needed | |
if ($url -match "^git@(.+):(.+)$") { | |
$url = "https://$($matches[1])/$($matches[2] -replace '\.git$','')" | |
} elseif ($url -match "^https://") { | |
$url = $url -replace '\.git$','' | |
} | |
Write-Host "Opening $url in browser..." | |
Start-Process $url | |
} | |
# oc stands for opencommit | |
function oc { | |
param ( | |
[string]$commitHash | |
) | |
if (-not $commitHash) { | |
throw "Commit hash is required. Usage: oc <commit-hash>" | |
} | |
$url = git config --get remote.origin.url | |
# Convert SSH URL to HTTPS if needed | |
if ($url -match "^git@(.+):(.+)$") { | |
$url = "https://$($matches[1])/$($matches[2] -replace '\.git$','')" | |
} elseif ($url -match "^https://") { | |
$url = $url -replace '\.git$','' | |
} | |
$commitUrl = "$url/commit/$commitHash" | |
Write-Host "Opening $commitUrl in browser..." | |
Start-Process $commitUrl | |
} | |
oh-my-posh init pwsh | Invoke-Expression |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment