Capture Windows Nushell config

This commit is contained in:
Riz Ashraf
2026-04-07 00:49:58 +01:00
parent 8b6c56b300
commit c33ea4edac
8 changed files with 5984 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
# vs-utils.nu
# Visual Studio environment management for Nushell
export def --env vcvars [] {
if ($env.VCINSTALLDIR? | is-not-empty) {
print "Visual Studio environment already initialized."
return
}
print "Initializing Visual Studio Developer Environment..."
# Bridge to PowerShell to get the environment variables
# The new pw7 function in env.nu already sources Gemini_Profile.ps1
let env_json = (pw7 '
$vsPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
if ($vsPath) {
$devShellModule = Get-ChildItem -Path "$vsPath\Common7\Tools" -Filter "Microsoft.VisualStudio.DevShell.dll" -Recurse | Select-Object -First 1 -ExpandProperty FullName
if ($devShellModule) {
Import-Module $devShellModule
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -Arch amd64 -NoLogo
Get-ChildItem env: | ForEach-Object { @{ Name = $_.Name; Value = $_.Value } } | ConvertTo-Json
}
}
' | from json)
if ($env_json | is-empty) {
print "Error: Could not initialize Visual Studio environment."
return
}
# Load the environment variables into Nushell
let new_env = ($env_json | reduce -f {} {|it, acc| $acc | insert $it.Name $it.Value })
# Path handling
load-env $new_env
# Convert Path string from PS back to Nu List if necessary
if ($env.Path? | is-not-empty) {
$env.PATH = ($env.Path | split row (char esep))
}
print "Visual Studio 2026 Developer Environment initialized."
}