24 lines
449 B
Text
24 lines
449 B
Text
|
#! /usr/bin/env nu
|
||
|
|
||
|
let env_vars_file = '/tmp/nushell-env-vars'
|
||
|
if not ($env_vars_file | path exists) {
|
||
|
open /etc/profile
|
||
|
| lines
|
||
|
| select 11
|
||
|
| str trim
|
||
|
| split column ' ' del path
|
||
|
| get path.0
|
||
|
| open $in
|
||
|
| str trim
|
||
|
| lines
|
||
|
| parse 'export {name}="{value}"'
|
||
|
| transpose --header-row --as-record
|
||
|
| tee {load-env $in}
|
||
|
| to nuon
|
||
|
| save --force $env_vars_file
|
||
|
} else {
|
||
|
open $env_vars_file
|
||
|
| from nuon
|
||
|
| load-env $in
|
||
|
}
|