improve direnv

This commit is contained in:
Jason Swank
2025-12-19 17:27:33 +00:00
parent e55369aa3e
commit f29b4cfd9d
2 changed files with 16 additions and 1 deletions

View File

@@ -1,2 +1,2 @@
[global] [global]
load_dotenv = true load_dotenv = false

View File

@@ -0,0 +1,15 @@
export_secret() {
local name="$1"
local file="/run/secrets/${name}"
if [[ ! -f "$file" ]]; then
printf "secret file not found: %s\n" $file >&2
return 1
fi
# Read first line, remove trailing spaces/tabs, convert nulls to newlines
local value
value=$(head -n1 "$file" | sed 's/[ \t]*$//' | tr '\0' '\n')
export "${name}=${value}"
}