fix(fish): use --in-file for op inject to fix stdin issue in command substitution

This commit is contained in:
2026-04-13 20:13:38 +08:00
parent 067608f4f8
commit 3c6910cfb1
3 changed files with 5 additions and 3 deletions
-1
View File
@@ -1,6 +1,5 @@
{
inputs,
lib,
username,
pkgs,
...
+4 -2
View File
@@ -64,12 +64,14 @@ in
source ~/.config/fish/local.fish
end
# 1Password env vars (single op call, silent if locked)
# 1Password env vars (single op call, silent on failure)
function op-env --description "Load secrets from 1Password"
if not type -q op; or not test -f ${envTpl}
return 1
end
for line in (op inject < ${envTpl} 2>/dev/null)
set -l output (op inject --in-file ${envTpl} 2>/dev/null)
or return 1
for line in $output
string match -qr '^\s*(#|$)' -- $line; and continue
set -l kv (string split -m 1 '=' $line)
if test (count $kv) -ge 2