Japanese: https://zenn.dev/bony_chops/articles/25024f5b13d7a6
-
Run
# Bitwarden CLI installition, you can use other options as well npm install -g @bitwarden/cli # keymaster installition cd $(mktemp -d) git clone --depth 1 https://github.com/BonyChops/keymaster.git cd keymaster swiftc keymaster.swift -o keymaster mkdir -p ~/.local/bin mv keymaster ~/.local/bin cd # Set path to ~/.local/bin if you haven't # bw.sh, bw-env.sh download mkdir -p ~/scripts wget -O ~/scripts/bw.sh https://gist.github.com/BonyChops/fecc50786cb36dc286ebbc3b5c33a3fa/raw/bw.sh wget -O ~/scripts/bw-env.sh https://gist.github.com/BonyChops/fecc50786cb36dc286ebbc3b5c33a3fa/raw/bw-env.sh
-
Edit
~/scripts/bw.shnano ~/scripts/bw.sh # use your favorite editor
-export BW_USER='xxx@xxx' +export BW_USER='YOUR_ACTUAL_EMAIL@example.com' # Keychain 上のキー名(ユーザーごとに分けたいならここを工夫) export BW_KEY_NAME="BW_SESSION_${BW_USER}" # ...
-
Add those on
~/.zshrcsource ~/scripts/bw.sh source ~/scripts/bw-env.shAnd apply it
source ~/.zshrc
-
bwpreparebw --regenerate-session-key
-
Done
Warning
This process must be performed in a Git-managed directory where the origin remote and its URL are configured.
If not configured, create a .bw-env file and write an arbitrary name inside it (this name will be used for the Secure Note name).
-
cdinto the directory where you are using.env. -
Use
bw-env upto add your.envas a Bitwarden Secure Note.$ bw-env up Uploading your .env as 📝 env:git@github.com:BonyChops/foobar.git Successfully uploaded your .env as 📝 env:git@github.com:BonyChops/foobar.git Tip: Now you can try run `bw-env show` to test. If it works, you can: Tip: rm .env -
Confirm with
bw-env show.You can also confirm this by checking inside the
envsfolder from the Bitwarden client.$ bw-env show TEST_SECRET=pass # OK if the expected content is visible -
Remove
.envafter uploading.rm .env
-
When you need to use the variables, just run
bw-env.$ bw-env Loaded environment variables from 📝 env:git@github.com:BonyChops/foobar.git into current shell. $ node index.js # The secret variables will be applied $ exit # They will not be reflected in a new shell (you need to run `bw-env` each time)
Footnotes
-
[Biometric unlock for Bitwarden CLI - Feature Requests / Password Manager - Bitwarden Community Forums] ↩
This threads can be used either Japanese or English :)