feat(fish/envsource): filter out empty lines and vars that don't comply with the standard VAR=VALUE format
This commit is contained in:
parent
eb6e2dfa39
commit
5a73a7a9a2
2 changed files with 8 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
alias ls 'exa -alh'
|
alias ls 'exa -alh'
|
||||||
alias g 'git'
|
alias g 'git'
|
||||||
alias copy 'xclip -selection clipboard'
|
alias copy 'xclip -selection clipboard'
|
||||||
alias cat 'bat'
|
alias cat 'bat --theme Catppuccin-frappe'
|
||||||
alias k 'kubectl'
|
alias k 'kubectl'
|
||||||
alias rm 'trash'
|
alias rm 'trash'
|
||||||
alias future-commit 'git commit --date (echo (date -d +7hours))'
|
alias future-commit 'git commit --date (echo (date -d +7hours))'
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
function envsource
|
function envsource
|
||||||
for line in (cat $argv | grep -v '^#')
|
if not set -q argv[1]
|
||||||
|
set argv[1] ".env"
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "Using $argv[1] as input file"
|
||||||
|
|
||||||
|
for line in (grep -v '^\s*\(#\|$\)' $argv[1] | grep -E '^[A-Za-z_]+=[^#\n]+')
|
||||||
set item (string split -m 1 '=' $line)
|
set item (string split -m 1 '=' $line)
|
||||||
set -gx $item[1] $item[2]
|
set -gx $item[1] $item[2]
|
||||||
echo "Exported key $item[1]"
|
echo "Exported key $item[1]"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue