Skip to content

Commit b54471e

Browse files
committed
feat(dots): simplified secrets.env
1 parent c34e729 commit b54471e

File tree

5 files changed

+37
-16
lines changed

5 files changed

+37
-16
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
config/fish/secrets.env filter=git-crypt diff=git-crypt
1+
config/secrets.env filter=git-crypt diff=git-crypt

config/fish/conf.d/secrets.fish

Lines changed: 0 additions & 15 deletions
This file was deleted.

config/fish/config.fish

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
status is-interactive; or exit
44

5+
# Load secrets if available
6+
dotenv ~/dot/secrets.env
7+
58
# Cursor styles
69
set -gx fish_vi_force_cursor 1
710
set -gx fish_cursor_default block

config/fish/functions/dotenv.fish

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function dotenv -d "Source environment variables from a file or .env in current directory" -a file
2+
set -l env_file
3+
4+
if test -z "$file"
5+
# No argument, use .env in current directory
6+
set env_file .env
7+
else
8+
# Use provided file path
9+
set env_file $file
10+
end
11+
12+
# Check if file exists
13+
if not test -f $env_file
14+
set_color red
15+
echo -n "[dotenv] "
16+
set_color normal
17+
echo "$env_file not found" >&2
18+
return 1
19+
end
20+
21+
# Source the file
22+
while read -l line
23+
# Skip empty lines and comments
24+
if test -n "$line"; and not string match -qr '^\s*#' -- $line
25+
# Export the variable
26+
set -l parts (string split -m 1 '=' -- $line)
27+
if test (count $parts) -eq 2
28+
set -gx $parts[1] $parts[2]
29+
end
30+
end
31+
end <$env_file
32+
end

secrets.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PVE_API_KEY=root@pam!vdi=b1499e0f-8d6f-459a-b0ee-cd02bbb466ad

0 commit comments

Comments
 (0)