From fe0f355277b220f304b2e58695349add20741e91 Mon Sep 17 00:00:00 2001 From: kj-sh604 Date: Wed, 17 Jul 2024 22:27:14 -0400 Subject: feat: new POSIX and fish functions --- .config/shell/posix-functions/POSIX_open.sh | 6 ++++++ .config/shell/posix-functions/create_POSIX_dotenv.sh | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 .config/shell/posix-functions/POSIX_open.sh create mode 100644 .config/shell/posix-functions/create_POSIX_dotenv.sh (limited to '.config/shell/posix-functions') diff --git a/.config/shell/posix-functions/POSIX_open.sh b/.config/shell/posix-functions/POSIX_open.sh new file mode 100644 index 0000000..b53e93f --- /dev/null +++ b/.config/shell/posix-functions/POSIX_open.sh @@ -0,0 +1,6 @@ +open() { + command -v xdg-open > /dev/null && xdg-open "$@" && return + [ "$(uname)" = "Darwin" ] && open "$@" && return + [ "$(uname)" = "Haiku" ] && open "$@" && return + echo "error: could not detect the open command for your system." && return 1 +} 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 +} -- cgit v1.2.3