aboutsummaryrefslogtreecommitdiff
path: root/.config/shell/posix-functions/create_POSIX_dotenv.sh
diff options
context:
space:
mode:
authorkj-sh6042024-07-17 22:27:14 -0400
committerkj-sh6042024-07-17 22:27:14 -0400
commitfe0f355277b220f304b2e58695349add20741e91 (patch)
treef140ce64ac2bc7bf124a74bf81ca0bdb6c4446ee /.config/shell/posix-functions/create_POSIX_dotenv.sh
parent311ea8ad7c5049ac9efec309b35073b19638054b (diff)
feat: new POSIX and fish functions
Diffstat (limited to '.config/shell/posix-functions/create_POSIX_dotenv.sh')
-rw-r--r--.config/shell/posix-functions/create_POSIX_dotenv.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/.config/shell/posix-functions/create_POSIX_dotenv.sh b/.config/shell/posix-functions/create_POSIX_dotenv.sh
new file mode 100644
index 0000000..9e5121d
--- /dev/null
+++ b/.config/shell/posix-functions/create_POSIX_dotenv.sh
@@ -0,0 +1,16 @@
+create_POSIX_dotenv() {
+ if [ -f .env ]; then
+ echo "# auto-generated .env.sh file" > .env.sh
+ while IFS= read -r line; do
+ if [ "${line#\#}" != "$line" ] || [ -z "$line" ]; then
+ continue
+ fi
+ key=$(echo "$line" | cut -d '=' -f 1)
+ value=$(echo "$line" | cut -d '=' -f 2-)
+ echo "export $key=\"$value\"" >> .env.sh
+ done < .env
+ echo ".env.sh file created successfully."
+ else
+ echo ".env file not found in current directory."
+ fi
+}