nushell.github.io
nushell.github.io copied to clipboard
env command doesn't output table data
nu: 0.79.0
I've found no env
builtin command documented on site, while it's told that this command is new:
or for a more detailed view, use our new env command.
env
used to be a built in but it isn't any longer. The docs need to be updated. These days I use this
# get the environment details
def "env details" [] {
let e = ($env | reject config | transpose key value)
$e | each { |r|
let is_envc = ($r.key == ENV_CONVERSIONS)
let is_closure = ($r.value | describe | str contains 'closure')
let is_list = ($r.value | describe | str contains 'list')
if $is_envc {
echo [[key value];
[($r.key) ($r.value | transpose key value | each { |ec|
let to_string = ($ec.value | get to_string | view source $in | nu-highlight)
let from_string = ($ec.value | get from_string | view source $in | nu-highlight)
echo ({'ENV_CONVERSIONS': {($ec.key): { 'to_string': ($to_string) 'from_string': ($from_string)}}})
})]
]
} else if $is_closure {
let closure_value = (view source ($env | get $r.key) | nu-highlight)
echo [[key value]; [($r.key) ($closure_value)]]
} else if $is_list {
let list_value = ($env | get $r.key | split row (char esep))
echo [[key value]; [($r.key) ($list_value)]]
} else {
echo [[key value]; [($r.key) ($r.value)]]
}
}
}
def env [] { env details | flatten | table -e }
The doc was updated at some point to reference the now-correct $env
- I think this can be closed?
Thanks for going through that backlog and caring for the documentation @NotTheDr01ds !
Most certainly! Trying to get the queue whittled down a bit as I can ;-)