Skip to content

Instantly share code, notes, and snippets.

@iqfareez
Created September 30, 2025 03:07
Show Gist options
  • Save iqfareez/4dd283af7d102086ed0dc72874d3d1c8 to your computer and use it in GitHub Desktop.
Save iqfareez/4dd283af7d102086ed0dc72874d3d1c8 to your computer and use it in GitHub Desktop.
My PowerShell alias function

Fareez PowerShell Profile script

Functions

  • oc - Open commit details on Remote
  • op - Open Remote Repository page
# 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