From 64218e084ebf94365db0b00662c1acfb99248f40 Mon Sep 17 00:00:00 2001 From: FivePixels Date: Sat, 28 Jan 2023 17:53:08 -0600 Subject: Add env file for sourcing, load dots feature --- .config/fish/functions/envsource.fish | 7 +++++++ .config/fish/functions/load_dots.fish | 21 +++++++++++++++++++++ .config/git/config | 5 ----- 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 .config/fish/functions/envsource.fish create mode 100644 .config/fish/functions/load_dots.fish delete mode 100644 .config/git/config diff --git a/.config/fish/functions/envsource.fish b/.config/fish/functions/envsource.fish new file mode 100644 index 0000000..dbcce39 --- /dev/null +++ b/.config/fish/functions/envsource.fish @@ -0,0 +1,7 @@ +function envsource + for line in (cat $argv | grep -v '^#' | grep -v '^\s*$') + set item (string split -m 1 '=' $line) + set -gx $item[1] (string trim --chars=\'\" $item[2]) + echo $item[1] + end +end diff --git a/.config/fish/functions/load_dots.fish b/.config/fish/functions/load_dots.fish new file mode 100644 index 0000000..249bea9 --- /dev/null +++ b/.config/fish/functions/load_dots.fish @@ -0,0 +1,21 @@ +function load_dots + for option in $argv + switch "$option" + case git + load_git + case \* + printf "error: Unknown option %s\n" $option + end + end +end + +function load_git + envsource ~/.env | while read -l env_var + switch $env_var + case "GIT_*" + # Handle git config variables + string lower (string replace -a '_' '.' (string replace -a GIT_ '' $env_var)) | read git_config_key + git config --global $git_config_key $$env_var + end + end +end diff --git a/.config/git/config b/.config/git/config deleted file mode 100644 index dd1d5ca..0000000 --- a/.config/git/config +++ /dev/null @@ -1,5 +0,0 @@ -[user] - name = FivePixels - email = o5pxels@gmail.com -[credential] - helper = store -- cgit v1.2.3