A lightweight python wrapper for the Bitwarden CLI.
- Session management: Unlock your Bitwarden vault once and cache the session token securely.
cp
/copy
subcommand: Copy a password to the clipboard.- Auto‑clear: Automatically clears the clipboard after a configurable timeout.
- YAML config: Easy configuration using a YAML file.
- UNIX
- Python 3+ with
pyyaml
- Bitwarden CLI
bw
- Clipboard management like
xsel
orwl-clipboard
- Get the script from the repository and install somewhere in your
PATH
wget https://raw.githubusercontent.com/msladek/bwx/refs/heads/main/bwx.py chmod +x bwx mv bwx.py ~/bin/bwx
- Create a config fitting your needs, see
Configuration
section below:edit ~/.config/bwx.yml
bwx <command>
See Bitwarden CLI documentation for available commands.
bwx cp <item>
Alias | Command |
---|---|
bwx pw <item> |
bw get password <item> |
Option | Default | Description |
---|---|---|
debug |
False |
Toggle debug logging |
transient_dir |
/run/user/<uid> |
Directory for session cache |
bw_cmd |
"bw" |
Bitwarden CLI command |
clipboard_copy_cmd |
[] (disabled) |
Clipboard copy command |
clipboard_clear_cmd |
[] (disabled) |
Clipboard clear command |
clipboard_clear_timeout |
30 |
Seconds before auto-clear |
You can override the default config by creating a YAML file. The script will look for config files in:
<script_dir>/bwx.yml
/.yaml
~/.config/bwx.yml
/.yaml
/etc/bwx.yml
/.yaml
debug: false
transient_dir: "$XDG_RUNTIME_DIR" # ramdisk strongly recommended
bw_cmd: "bw" # in PATH or FQN
clipboard_copy_cmd: # disabled if empty
- "xsel"
- "--input"
- "--clipboard"
clipboard_clear_cmd: # disabled if empty
- "xsel"
- "--clear"
- "--clipboard"
clipboard_clear_timeout: 30 # seconds