1111# init-app reset-env-path
1212#
1313# .NOTES
14- # Not working on NuShell yet, hence moved to init.nu for now
1514# Targeting apps i.e., choco, python (ML).
1615# Required Env Vars:
1716# - $pfiles_x64_dir
1817#------------------------------------------------------------------------------
1918
2019def main [
21- app_name : string = ' reset-env-path' # Name of app for which to init
20+ app_name : string = ' reset-env-path' # Name of app for which to init
2221] {
2322 print $" Init for app: ($app_name )"
24- # ShellHome from config.nu isn't available here on win for some reason
25- let ShellHome = " D:\\ Code\\ shell"
26- let pfiles_x64_dir = " C:\\ PFiles_x64\\ choco"
2723
28- print $" Current env Path: ($env .Path )"
24+ let pfiles_x64_dir = " C:\\ PFiles_x64\\ choco"
25+ let prior_env_path = $env .Path
2926
3027 match $app_name {
3128 ' git' => {
3229 let git_path = ($pfiles_x64_dir | path join ' git' ' cmd' )
33- $env .Path = ($env .Path | append $git_path )
34- # $env.Path = ($env.Path | append "C:\\PFiles_x64\\choco\\git\\cmd")
35- print $" Added to PATH: ($git_path )"
30+ let path_with_git = ($prior_env_path | append $git_path )
31+ $path_with_git
3632 }
3733 ' reset-env-path' => {
38- # Example: Reset PATH to default
39- $env .Path = ( [
34+ # Reset PATH to default
35+ [
4036 ($env .SystemRoot | path join ' system32' ),
4137 $env .SystemRoot ,
4238 ($env .SystemRoot | path join ' System32' ' Wbem' ),
4339 ($env .LOCALAPPDATA | path join ' Microsoft' ' WindowsApps' ),
44- $ShellHome ,
4540 ($env .SystemRoot | path join ' System32' ' OpenSSH' ),
46- ($env .SystemRoot | path join ' System32' ' WindowsPowerShell' ' v1.0' )
47- ])
41+ ($env .SystemRoot | path join ' System32' ' WindowsPowerShell' ' v1.0' ),
42+ $ShellHome
43+ ]
4844 }
4945 _ => {
5046 print $" Invalid command line argument: ($app_name )"
47+ $prior_env_path
5148 }
5249 }
53-
54- print $" Updated env Path: ($env .Path )"
5550}
0 commit comments