Last active
August 3, 2022 20:24
-
-
Save WorldMaker/cba729e77226ecbff933b265d53f7823 to your computer and use it in GitHub Desktop.
PowerShell snippets
This file contains 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
# A simple wrapper function for the pattern of run a command and if the command succeeds | |
# commit all the changes to git with a git commit message of the command line prefixed | |
# with a wrench (🔧) | |
function Invoke-GitExpression { | |
param( | |
[string[]] | |
[Parameter(ValueFromRemainingArguments)] | |
$Remaining | |
) | |
Invoke-Expression "$Remaining" | |
if ($LASTEXITCODE -eq 0) { | |
git add -A | |
git commit -m "🔧 $Remaining" | |
} | |
} | |
Set-Alias wrench Invoke-GitExpression |
This file contains 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
# The http.exe wrapper for httpie (.org) keeps getting flagged as a false positive for malware by corporate security tools, | |
# so here's a wrapper function and alias to replace it by calling through the main Python exe. | |
function Invoke-Httpie { | |
param( | |
[string[]] | |
[Parameter(ValueFromRemainingArguments)] | |
$Remaining | |
) | |
python -m httpie $Remaining | |
} | |
Set-Alias http Invoke-Httpie |
This file contains 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
# A simple GUI multi-selector for removing merged git branches in reasonable bulk | |
function Remove-GitBranches { | |
git branch --merged | Out-GridView -Title "Branches to Remove?" -OutputMode Multiple | % { git branch -d $_.Trim() } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment