feat: split loadenv from readenv to load any file
This commit is contained in:
parent
7a15fceb1b
commit
50cae027bc
|
@ -70,8 +70,7 @@ if status is-interactive
|
|||
# === auto cd into last activated directory
|
||||
test "$PWD" = "$HOME" && cd $last_pwd
|
||||
|
||||
function readenv --on-variable PWD
|
||||
if test -r .env
|
||||
function loadenv
|
||||
while read -l line
|
||||
set -l line (string trim $line)
|
||||
if [ -z "$line" ]
|
||||
|
@ -82,7 +81,12 @@ if status is-interactive
|
|||
end
|
||||
set -l kv (string split -m 1 = -- $line)
|
||||
set -gx $kv
|
||||
end < .env
|
||||
end < $argv[1]
|
||||
end
|
||||
|
||||
function readenv --on-variable PWD
|
||||
if test -r .env
|
||||
loadenv .env
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user