mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-10-26 13:55:28 +03:00
add windows compatibility for command not found hook (#811)
the hook (did_you_mean.nu) had stopped working for me recently, I added an if branch for Windows to use their `Path` env var (not `PATH`) and only list files that match in the `PATHEXT` env var to resolve my issue
This commit is contained in:
parent
df90d65eec
commit
554cb31819
@ -18,9 +18,18 @@
|
|||||||
# ```
|
# ```
|
||||||
{|cmd|
|
{|cmd|
|
||||||
let commands_in_path = (
|
let commands_in_path = (
|
||||||
$env.PATH | each {|directory|
|
if ($nu.os-info.name == windows) {
|
||||||
if ($directory | path exists) {
|
$env.Path | each {|directory|
|
||||||
ls $directory | get name | path parse | update parent "" | path join
|
if ($directory | path exists) {
|
||||||
|
let cmd_exts = $env.PATHEXT | str downcase | split row ';' | str trim --char .
|
||||||
|
ls $directory | get name | path parse | where {|it| $cmd_exts | any {|ext| $ext == ($it.extension | str downcase)} } | get stem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$env.PATH | each {|directory|
|
||||||
|
if ($directory | path exists) {
|
||||||
|
ls $directory | get name | path parse | update parent "" | path join
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| flatten
|
| flatten
|
||||||
|
Loading…
Reference in New Issue
Block a user