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
|
# === auto cd into last activated directory
|
||||||
test "$PWD" = "$HOME" && cd $last_pwd
|
test "$PWD" = "$HOME" && cd $last_pwd
|
||||||
|
|
||||||
function readenv --on-variable PWD
|
function loadenv
|
||||||
if test -r .env
|
|
||||||
while read -l line
|
while read -l line
|
||||||
set -l line (string trim $line)
|
set -l line (string trim $line)
|
||||||
if [ -z "$line" ]
|
if [ -z "$line" ]
|
||||||
|
@ -82,7 +81,12 @@ if status is-interactive
|
||||||
end
|
end
|
||||||
set -l kv (string split -m 1 = -- $line)
|
set -l kv (string split -m 1 = -- $line)
|
||||||
set -gx $kv
|
set -gx $kv
|
||||||
end < .env
|
end < $argv[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
function readenv --on-variable PWD
|
||||||
|
if test -r .env
|
||||||
|
loadenv .env
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user