Skip to content

Instantly share code, notes, and snippets.

@powderluv
Created December 18, 2025 09:52
Show Gist options
  • Select an option

  • Save powderluv/79d82c3369aecb62d62d8e674c5e26f4 to your computer and use it in GitHub Desktop.

Select an option

Save powderluv/79d82c3369aecb62d62d8e674c5e26f4 to your computer and use it in GitHub Desktop.
Powershell Profile PS1
# Stick this in C:\Users\<login>\OneDrive\Documents\PowerShell\
# Test-Path -Path $PROFILE
# New-Item -ItemType File -Path $PROFILE -Force
# code $PROFILE
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
# Check if vswhere exists, if not you may need to adjust the path or install the VS installer
if (-not (Test-Path $vswhere)) {
Write-Host "vswhere.exe not found at the expected location."
# Provide a link to the official vswhere documentation if needed
}
$vcvarspath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
Write-Host "VC tools located at: $vcvarspath"
# Use cmd.exe to call the batch file and 'set' the variables to a temp file, then import them into PowerShell
cmd.exe /c "call `"$vcvarspath\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars.txt"
Get-Content "$env:temp\vcvars.txt" | Foreach-Object {
if ($_ -match "^(.*?)=(.*)$") {
Set-Content "env:\$($matches[1])" $matches[2]
}
}
Remove-Item "$env:temp\vcvars.txt" # Clean up the temporary file
Write-Host "Environment variables for Visual Studio set in current session."
# You can now run commands like 'cl.exe' or 'msbuild'
write-host "`nVisual Studio 2026 Command Prompt variables set." -ForegroundColor Yellow
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadline
}
Set-PSReadlineOption -EditMode Vi
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadlineKeyHandler -Key Tab -Function Complete
Set-Alias vi "C:\Program Files\Neovim\bin\nvim.exe"
Set-Alias vim "C:\Program Files\Neovim\bin\nvim.exe"
$ENV:EDITOR = "vi"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment