refactor(fish): extract op-env into reloadable function and skip comment lines

This commit is contained in:
2026-04-13 15:46:19 +08:00
parent 82ab946ba1
commit 09463d0dbb
+6 -1
View File
@@ -61,14 +61,19 @@
end
# 1Password env vars (single op call, silent if locked)
if type -q op; and test -f ~/.config/op/env.tpl
function op-env --description "Load secrets from 1Password"
if not type -q op; or not test -f ~/.config/op/env.tpl
return 1
end
for line in (op inject < ~/.config/op/env.tpl 2>/dev/null)
string match -qr '^\s*(#|$)' -- $line; and continue
set -l kv (string split -m 1 '=' $line)
if test (count $kv) -ge 2
set -gx $kv[1] $kv[2]
end
end
end
op-env
'';
};
}