vitorpy's Dotfiles
1# Fish Shell Secrets Configuration
2# This file sources secrets from Bitwarden CLI if available
3
4# Check if Bitwarden CLI is available and we have a session
5if command -v bw &> /dev/null
6 # Check if BW_SESSION is set
7 if test -n "$BW_SESSION"
8 # Helper function to get secret from Bitwarden
9 function get_bitwarden_secret
10 set -l item_name $argv[1]
11
12 # Get the secret password field and suppress errors
13 bw get password "$item_name" --session "$BW_SESSION" 2>/dev/null
14 end
15
16 # Set ANTHROPIC_API_KEY
17 set -l anthropic_key (get_bitwarden_secret "Anthropic API Key")
18 if test -n "$anthropic_key"
19 set -gx ANTHROPIC_API_KEY "$anthropic_key"
20 end
21
22 # Set NPM_TOKEN for npmrc
23 set -l npm_token (get_bitwarden_secret "NPM Registry Token")
24 if test -n "$npm_token"
25 set -gx NPM_TOKEN "$npm_token"
26 end
27
28 else
29 # BW_SESSION not set
30 echo "BW_SESSION not set. Run: export BW_SESSION=\$(bw unlock --raw)" >&2
31 end
32else
33 # Bitwarden CLI not installed
34 echo "Bitwarden CLI not installed. Run: brew install bitwarden-cli" >&2
35end