mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-03-20 08:06:42 +00:00
feat(fish): add secrets.d for secret env vars
Add config/fish/secrets.d/ directory pattern to .gitignore while allowing *.example and README.md through. Add README and example file documenting the secrets convention. Source secrets.d/*.fish files in exports.fish so secret environment variables are loaded automatically.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -29,6 +29,9 @@ config/fish/completions/kubectl.fish
|
||||
config/fish/completions/orbctl.fish
|
||||
config/fish/fish_variables
|
||||
config/fish/fish_variables.*
|
||||
config/fish/secrets.d/*
|
||||
!config/fish/secrets.d/*.example
|
||||
!config/fish/secrets.d/README.md
|
||||
config/gh/hosts.yml
|
||||
config/git/credentials
|
||||
config/git/local.d/*
|
||||
|
||||
@@ -180,6 +180,15 @@ if test -f "$DOTFILES/hosts/$HOSTNAME/config/fish/exports-secret.fish"
|
||||
source "$DOTFILES/hosts/$HOSTNAME/config/fish/exports-secret.fish"
|
||||
end
|
||||
|
||||
# Source secret environment variables from secrets.d directory
|
||||
if test -d "$DOTFILES/config/fish/secrets.d"
|
||||
for secret_file in "$DOTFILES/config/fish/secrets.d"/*.fish
|
||||
if test -f "$secret_file"
|
||||
source "$secret_file"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Configure tide prompt
|
||||
set -gx tide_prompt_transient_enabled true
|
||||
set -gx tide_prompt_add_newline_before true
|
||||
|
||||
72
config/fish/secrets.d/README.md
Normal file
72
config/fish/secrets.d/README.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# Fish Shell Secrets Directory
|
||||
|
||||
This directory contains sensitive environment variables like API tokens and credentials.
|
||||
|
||||
## Usage
|
||||
|
||||
1. Copy an example file (e.g., `github.fish.example`) to remove the `.example` suffix:
|
||||
|
||||
```bash
|
||||
cp github.fish.example github.fish
|
||||
```
|
||||
|
||||
2. Edit the file and replace placeholder values with your actual secrets:
|
||||
|
||||
```bash
|
||||
$EDITOR github.fish
|
||||
```
|
||||
|
||||
3. Reload your fish shell or source the exports:
|
||||
|
||||
```fish
|
||||
source ~/.config/fish/exports.fish
|
||||
```
|
||||
|
||||
## Adding New Secret Files
|
||||
|
||||
Create a new `.fish` file in this directory with your environment variables:
|
||||
|
||||
```fish
|
||||
# Example: openai.fish
|
||||
set -x OPENAI_API_KEY "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
```
|
||||
|
||||
Common secret patterns:
|
||||
|
||||
- `github.fish` - GitHub Personal Access Token (`GITHUB_TOKEN`)
|
||||
- `aws.fish` - AWS credentials (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`)
|
||||
- `openai.fish` - OpenAI API key (`OPENAI_API_KEY`)
|
||||
- `anthropic.fish` - Anthropic API key (`ANTHROPIC_API_KEY`)
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
- **Never commit actual secrets** - Only `.example` files are tracked by git
|
||||
- **Use specific permissions** - Consider `chmod 600` for secret files
|
||||
- **Rotate credentials regularly** - Update tokens when compromised
|
||||
- **Use environment-specific files** - Separate dev/staging/prod credentials
|
||||
- **Check before committing** - Run `git status` to verify secrets aren't staged
|
||||
|
||||
## How It Works
|
||||
|
||||
The `exports.fish` file automatically sources all `*.fish` files from this directory:
|
||||
|
||||
```fish
|
||||
if test -d "$DOTFILES/config/fish/secrets.d"
|
||||
for secret_file in "$DOTFILES/config/fish/secrets.d"/*.fish
|
||||
if test -f "$secret_file"
|
||||
source "$secret_file"
|
||||
end
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
Files ending in `.example` are ignored by the loader but tracked by git as templates.
|
||||
|
||||
## Backward Compatibility
|
||||
|
||||
This directory supplements the existing `exports-secret.fish` pattern. Both methods work:
|
||||
|
||||
- **Legacy**: `config/fish/exports-secret.fish` (single file, still supported)
|
||||
- **New**: `config/fish/secrets.d/*.fish` (multiple files, recommended)
|
||||
|
||||
Use whichever approach fits your workflow best.
|
||||
5
config/fish/secrets.d/github.fish.example
Normal file
5
config/fish/secrets.d/github.fish.example
Normal file
@@ -0,0 +1,5 @@
|
||||
# GitHub Personal Access Token
|
||||
# Copy this file to github.fish (remove .example) and set your token
|
||||
# Generate token at: https://github.com/settings/tokens
|
||||
|
||||
set -x GITHUB_TOKEN "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
Reference in New Issue
Block a user