Files
dotfiles/dot_config/nushell/nu_scripts/modules/formats/from-env.nu
Cian Hughes 896af887ca Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows)
and improves grepability with neovim/telescope
2024-11-07 13:52:17 +00:00

12 lines
331 B
Nu

# Converts a .env file into a record
# may be used like this: open .env | load-env
# works with quoted and unquoted .env files
def "from env" []: string -> record {
lines
| split column '#' # remove comments
| get column1
| parse "{key}={value}"
| str trim value -c '"' # unquote values
| transpose -r -d
}