diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 3dfe9ad..c78246a 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -61,6 +61,8 @@ source $ZSH/oh-my-zsh.sh # alias ohmyzsh="mate ~/.oh-my-zsh" alias bw='NODE_OPTIONS="--no-deprecation" bw' +alias bwu="export BW_SESSION=$(bw unlock --raw)" + export NODE_OPTIONS="--no-deprecation" # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. diff --git a/run_before_update_unlock_bitwarden.sh.tmpl b/run_before_update_unlock_bitwarden.sh.tmpl new file mode 100644 index 0000000..271243e --- /dev/null +++ b/run_before_update_unlock_bitwarden.sh.tmpl @@ -0,0 +1,27 @@ +#!/bin/bash + +# Function to check if Bitwarden CLI is installed +is_bw_installed() { + command -v bw >/dev/null 2>&1 +} + +# Function to unlock the Bitwarden vault +unlock_vault() { + echo "Unlocking Bitwarden vault..." + BW_SESSION=$(bw unlock --raw) + export BW_SESSION + if [ -n "$BW_SESSION" ]; then + echo "Vault unlocked successfully." + bw sync + else + echo "Failed to unlock vault." + fi +} + +# Check if Bitwarden CLI is installed +if is_bw_installed; then + unlock_vault +else + echo "Bitwarden CLI is not installed, doing nothing." +fi +