diff --git a/nu-hooks/nu-hooks/direnv/config.nu b/nu-hooks/nu-hooks/direnv/config.nu index 6bcc2be..2cb7efc 100644 --- a/nu-hooks/nu-hooks/direnv/config.nu +++ b/nu-hooks/nu-hooks/direnv/config.nu @@ -23,4 +23,8 @@ } direnv export json | from json | default {} | load-env + # Direnv outputs $PATH as a string, but nushell silently breaks if isn't a list-like table. + # The following behemoth of Nu code turns this into nu's format while following the standards of how to handle quotes, use it if you need quote handling instead of the line below it: + # $env.PATH = $env.PATH | parse --regex ('' + `((?:(?:"(?:(?:\\[\\"])|.)*?")|(?:'.*?')|[^` + (char env_sep) + `]*)*)`) | each {|x| $x.capture0 | parse --regex `(?:"((?:(?:\\"|.))*?)")|(?:'(.*?)')|([^'"]*)` | each {|y| if ($y.capture0 != "") { $y.capture0 | str replace -ar `\\([\\"])` `$1` } else if ($y.capture1 != "") { $y.capture1 } else $y.capture2 } | str join } + $env.PATH = $env.PATH | split row (char env_sep) }