Created
December 19, 2017 08:55
-
-
Save kidandcat/6943d870bba06a954bb08ea0c3b8c13b to your computer and use it in GitHub Desktop.
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
# Excluded commands to overwrite in PowerShell | |
$exclude = @("dir", "cd", "git", "node", "tsc", "magic", "npm", "code", "vsce", "set", "go", "jasmine", "flow", "parcel") | |
Set-PSReadlineKeyHandler -Key Tab -Function Complete | |
function bashFunc($cmd, $arg) {C:\windows\system32\bash.exe -c "sudo $cmd $arg"} | |
$MaximumFunctionCount = 30000 | |
$pat = "^[a-zA-Z0-9\s]+$" | |
$cmds = bash -c "compgen -ac" | |
$ErrorActionPreference = "SilentlyContinue" | |
foreach ($c in $cmds) { | |
if ($c -match $pat) { | |
if ($exclude.Contains("$c")) { | |
continue | |
} | |
Remove-Item Alias:$c | |
Set-Item -Path function:global:$c -Value { | |
$arguments = $args | |
$posixArgs = @() | |
foreach ($arg in $arguments) { | |
$arg = $arg.replace('C:', '/mnt/c') | |
$arg = $arg.replace('\', '/') | |
$posixArgs += $arg | |
} | |
Invoke-Expression "bashFunc(`"$($MyInvocation.MyCommand.Name)`", `"$posixArgs`")" | |
} | |
} | |
} | |
$ErrorActionPreference = "Stop" | |
function restoreGit { | |
$a = new-object -comobject wscript.shell | |
$intAnswer = $a.popup("Do you want to restore to UPSTREAM losing all changes?", 0, "Restore", 4) | |
If ($intAnswer -eq 6) { | |
git fetch upstream | |
git checkout master | |
git reset --hard upstream/master | |
git push origin master --force | |
} | |
} | |
Set-Alias restore restoreGit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment