···11# Fish Shell Secrets Configuration
22-# This file sources secrets from Keeper Commander if available
33-44-# Check if Keeper Commander is available and configured
55-if command -v keeper &> /dev/null
66- # Set keeper config path
77- set -l keeper_config "$HOME/.keeper/config.json"
22+# This file sources secrets from Bitwarden CLI if available
8399- # Check if config exists and we can access Keeper
1010- if test -f "$keeper_config"
1111-1212- # Helper function to get secret from Keeper
1313- function get_keeper_secret
1414- set -l record_uid $argv[1]
1515- set -l field $argv[2]
1616- set -l keeper_config "$HOME/.keeper/config.json"
44+# Check if Bitwarden CLI is available and we have a session
55+if command -v bw &> /dev/null
66+ # Check if BW_SESSION is set
77+ if test -n "$BW_SESSION"
88+ # Helper function to get secret from Bitwarden
99+ function get_bitwarden_secret
1010+ set -l item_name $argv[1]
17111818- # Get the secret and suppress errors
1919- keeper --config "$keeper_config" get "$record_uid" --format=json 2>/dev/null | python3 -c "
2020-import sys, json
2121-try:
2222- data = json.load(sys.stdin)
2323- if '$field' == 'password':
2424- print(data.get('password', ''), end='')
2525- elif '$field' == 'login':
2626- print(data.get('login', ''), end='')
2727- else:
2828- # Look in custom fields
2929- for field in data.get('custom', []):
3030- if field.get('name') == '$field':
3131- print(field.get('value', ''), end='')
3232- break
3333-except:
3434- pass
3535-"
1212+ # Get the secret password field and suppress errors
1313+ bw get password "$item_name" --session "$BW_SESSION" 2>/dev/null
3614 end
37153816 # Set ANTHROPIC_API_KEY
3939- set -l anthropic_key (get_keeper_secret "r_HJvm0objPd0IVpJS6sHw" "password")
1717+ set -l anthropic_key (get_bitwarden_secret "Anthropic API Key")
4018 if test -n "$anthropic_key"
4119 set -gx ANTHROPIC_API_KEY "$anthropic_key"
4220 end
43214422 # Set NPM_TOKEN for npmrc
4545- set -l npm_token (get_keeper_secret "UXmsbgffjKU-e3BnTZ1MpA" "password")
2323+ set -l npm_token (get_bitwarden_secret "NPM Registry Token")
4624 if test -n "$npm_token"
4725 set -gx NPM_TOKEN "$npm_token"
4826 end
49275028 else
5151- # Keeper config not found
5252- echo "Keeper config not found at ~/.keeper/config.json. Run: keeper --config ~/.keeper/config.json login" >&2
2929+ # BW_SESSION not set
3030+ echo "BW_SESSION not set. Run: export BW_SESSION=\$(bw unlock --raw)" >&2
5331 end
5432else
5555- # Keeper not installed - use fallback or prompt
5656- echo "Keeper Commander not installed. Run: ~/.local/share/chezmoi/scripts/setup-keeper-secrets.sh" >&2
5757-end
5858-5959-# Fallback: source local secrets file if it exists (for non-Keeper setup)
6060-if test -f ~/.config/fish/secrets.local.fish
6161- source ~/.config/fish/secrets.local.fish
3333+ # Bitwarden CLI not installed
3434+ echo "Bitwarden CLI not installed. Run: brew install bitwarden-cli" >&2
6235end