From 8ab66e607c73755b7bf29e8636e7bf7b82d6c089 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Fri, 27 Aug 2021 14:53:22 +0800 Subject: [PATCH] feat: autoload .env file and export --- cli/fish/config.fish | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cli/fish/config.fish b/cli/fish/config.fish index 312e7c8..910ac83 100644 --- a/cli/fish/config.fish +++ b/cli/fish/config.fish @@ -69,5 +69,21 @@ 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 + while read -l line + set -l line (string trim $line) + if [ -z "$line" ] + continue + end + if string match -q '#*' $line + continue + end + set -l kv (string split -m 1 = -- $line) + set -gx $kv + end < .env + end + end end