Skip to content

Instantly share code, notes, and snippets.

@voxxit
Last active August 5, 2022 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voxxit/a779edae41f861d74c00bf619e1fce54 to your computer and use it in GitHub Desktop.
Save voxxit/a779edae41f861d74c00bf619e1fce54 to your computer and use it in GitHub Desktop.
How to keep your .bashrc / .zshrc free of secrets!
############## 1Password Stuff ###############
# Check for 1Password CLI, and install if necessary:
command -v op >&- || brew install --cask 1password-cli
# You can simply export the 1Password secret's deep link in
# place of any sensitive value held in an environment variable:
export JIRA_API_TOKEN="op://example_vault/JIRA_API_TOKEN/credential"
# To use this at runtime, use: `op run -- <app> ..args..`
# Or, my preferred approach: make helper/wrapper functions:
jira() {
JIRA_API_TOKEN="op://example_vault/JIRA_API_TOKEN/credential" \
op run -- jira "$@"
}
# You can even use it for AWS MFA - every single day! (Hey! That rhymes...)
aws-mfa() {
/usr/local/bin/aws-mfa <<< $(op item get "aws-example" --otp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment