Capture Windows Nushell config
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# java-utils.nu
|
||||
# JDK management functions for Nushell (modern syntax)
|
||||
|
||||
export def --env set-jdk [path: string, --quiet (-q)] {
|
||||
let bin_path = ([$path, 'bin'] | path join)
|
||||
$env.JAVA_HOME = $path
|
||||
|
||||
# Update PATH: remove any entry that looks like a JDK bin and add the new one
|
||||
if ($env.PATH | describe | str contains 'list') {
|
||||
$env.PATH = ($env.PATH | where {|row|
|
||||
let is_jdk_bin = (($row | str contains 'jdk') and ($row | str ends-with 'bin'))
|
||||
not $is_jdk_bin
|
||||
} | prepend $bin_path)
|
||||
} else {
|
||||
let sep = (char esep)
|
||||
let path_list = ($env.PATH | split row $sep)
|
||||
$env.PATH = ($path_list | where {|row|
|
||||
let is_jdk_bin = (($row | str contains 'jdk') and ($row | str ends-with 'bin'))
|
||||
not $is_jdk_bin
|
||||
} | prepend $bin_path | str join $sep)
|
||||
}
|
||||
|
||||
if not $quiet {
|
||||
print $"JAVA_HOME set to: ($path)"
|
||||
try { java -version } catch { print "Warning: java command not found in new path." }
|
||||
}
|
||||
}
|
||||
|
||||
export def --env jdk8home [--quiet (-q)] {
|
||||
set-jdk 'C:\Program Files\Eclipse Adoptium\jdk-8.0.482.8-hotspot' --quiet=$quiet
|
||||
}
|
||||
|
||||
export def --env jdk8home32 [--quiet (-q)] {
|
||||
set-jdk 'C:\Program Files (x86)\Eclipse Adoptium\jdk-8.0.472.8-hotspot' --quiet=$quiet
|
||||
}
|
||||
|
||||
export def --env jdk8home32Liberica [--quiet (-q)] {
|
||||
set-jdk 'C:\Users\reazul.ashraf\scoop\apps\liberica8-full-jdk\current' --quiet=$quiet
|
||||
}
|
||||
|
||||
export def --env jdk8homeCorretto [--quiet (-q)] {
|
||||
set-jdk 'C:\Users\reazul.ashraf\scoop\apps\corretto8-jdk\current' --quiet=$quiet
|
||||
}
|
||||
|
||||
export def --env jdk21home [--quiet (-q)] {
|
||||
set-jdk 'C:\Program Files\Eclipse Adoptium\jdk-21.0.10.7-hotspot' --quiet=$quiet
|
||||
}
|
||||
|
||||
export def --env jdk25home [--quiet (-q)] {
|
||||
set-jdk 'C:\Program Files\Eclipse Adoptium\jdk-25.0.2.10-hotspot' --quiet=$quiet
|
||||
}
|
||||
Reference in New Issue
Block a user