Skip to content

Instantly share code, notes, and snippets.

@tiagosomda
Last active March 5, 2022 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiagosomda/f6c97a9ffbfb686048895cca2c099b58 to your computer and use it in GitHub Desktop.
Save tiagosomda/f6c97a9ffbfb686048895cca2c099b58 to your computer and use it in GitHub Desktop.
Powershell Profile (git and visual studio shortcuts)
## include this on your powershell profile
function title
{
param([string] $title )
$Host.UI.RawUI.WindowTitle = $title
}
function refreshenv
{
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
}
function sln
{
$files = Get-ChildItem *.sln -Recurse
if($files.Count -eq 1)
{
Start-Process $files[0].FullName
}
else
{
$solutions = "`n More than one solution file found: `n`n"
$count = 0;
$files | ForEach-Object {
$solutions += " $count) " + $_.Name + "`n"
$count++;
}
$solutions += "`n x) to cancel `n"
Write-Host $solutions
$selection = Read-Host -Prompt ' Which solution would you like to open?'
Write-Host "`n"
if ($selection -match "^[\d\.]+$" -and ($selection -ge 0 -and $selection -le $files.Length -1))
{
$index = [int]$selection
$fileName = $files[$index].FullName
Write-Host " Opening $fileName ...`n"
Start-Process $fileName
}
}
}
function gito
{
$url = git config --get remote.origin.url
if($url) {
$url = $url.replace(".git","").replace("git@github.com:", "https://www.github.com/")
Start-Process $url
} else {
Write-Warning "Nothing returned by 'git config --get remote.origin.url'"
}
}
function gitpr {
$url = git config --get remote.origin.url
if($url) {
$url += "/pullrequest"
Start-Process $url
} else {
Write-Warning "Nothing returned by 'git config --get remote.origin.url'"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment