Skip to content

Instantly share code, notes, and snippets.

@hugsy
Last active February 18, 2022 00:24
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 hugsy/fcde93d18bd88e48576014da75f71cec to your computer and use it in GitHub Desktop.
Save hugsy/fcde93d18bd88e48576014da75f71cec to your computer and use it in GitHub Desktop.
My PowerShell profile
Import-Module posh-git
Import-Module oh-my-posh
Import-Module -Name Terminal-Icons
Set-PoshPrompt slimfat
Set-PSReadlineOption -EditMode Emacs
Set-PSReadLineKeyHandler -Chord Ctrl+LeftArrow -Function BackwardWord
Set-PSReadLineKeyHandler -Chord Ctrl+RightArrow -Function NextWord
# Set-PSReadLineKeyHandler -Chord Ctrl+Backspace -Function BackwardKillWord
Set-PSReadLineKeyHandler -Chord Ctrl+f -ScriptBlock {Start-Process fzf -NoNewWindow}
Set-PSReadlineKeyHandler -Key Ctrl+d -Function DeleteCharOrExit
Function Invoke-CmdScript([String] $scriptName, [String] $args)
{
$cmdLine = '{0} {1} & set' -f $scriptName, $args
& $env:SystemRoot\system32\cmd.exe /c $cmdLine |
Select-String '^([^=]*)=(.*)$' | ForEach-Object {
$varName = $_.Matches[0].Groups[1].Value
$varValue = $_.Matches[0].Groups[2].Value
#echo "Setting Env:${varName} -> ${varValue}"
Set-Item Env:$varName $varValue
}
}
Function Invoke-VisualStudio2019x86
{
Invoke-CmdScript "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
}
Function Invoke-VisualStudio2019x64
{
Invoke-CmdScript "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
}
Function Invoke-Ewdk2022x64
{
param(
[Parameter()][ValidateSet("10.0.22000.0")][String] $Version = "10.0.22000.0",
[Parameter()][ValidateSet("amd64", "x86", "x86_amd64", "x86_arm", "x86_arm64")][String] $Platform = "amd64"
)
$scriptPath = "C:\wdk\" + $Version + "\BuildEnv\SetupBuildEnv.cmd"
Invoke-CmdScript $scriptPath, $Platform
}
Function Invoke-PowerShellAsAdmin
{
Start-Process powershell -Verb runas -PassThru
}
Remove-Item alias:curl
Remove-Item alias:wget
New-Alias -Name grep -Value findstr -Option ReadOnly
New-Alias -Name find -Value fd -Option ReadOnly
New-Alias -Name ipython -Value c:\users\hugsy\appdata\local\programs\python\python39\scripts\ipython.exe -Option ReadOnly
New-Alias -Name ipy -Value ipython -Option ReadOnly
New-Alias -Name cc -Value clang -Option ReadOnly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment