Home

Awesome

zsh-bitwarden

This plugin provides functions to manage a bitwarden session

Installation

See INSTALL.md.

Usage

CommandDescription
bwulunlock the vault
bwlklock the vault
bwstvault status
bwsnsync the vault
bwjsprint item json
bwjseedit item json in $EDITOR
bwtsv -tprint tsv table
bwtsvselect tsv data
bwtsv -tprint tsv table
bwgalphanum + special password
bwgsalphanum password
bwusget username
bwuseedit username
bwpwget password
bwpweedit password
bwflget field
bwfleedit field
bwfle -rrename field
bwfle -ddelete field
bwflaadd field
bwnoget note
bwnoeedit note
bwneedit item name
bwupcopy username then password
bwlccreate login
bwnccreate note

Examples

# copy password to clipboard and include .notes column in finder
bwpw .notes
# create entry called `mylogin` with username `user123@example.com` and copy secure password to clipboard
bwlc -n mylogin -u user123@example.com
# rename to mynewlogin
echo -n mynewlogin | bwne -s mylogin
# get username and password
bwup -s mynewlogin
# add field
echo -n myvalue | bwfla -s mynewlogin -f myfield
# copy field
bwfl -s mynewlogin -f myfield
# rename field to `newvalue`
echo -n newvalue | bwfle -s mynewlogin -f myfield -r

Search

bwtsv --simplify -s gmail -lc -c .name -c .username -o '.[] | .fields | length'

This command searches for "gmail" (-s gmail) and returns matching logins (-l). The use of -c along with argument .name causes the name of each item to be displayed in fzf. The use of -o along with '.[] | .fields | length' causes the number of fields to be displayed in fzf and also printed to output when selected.

CharacterVisible in fzfPrinted to output
cyesno
oyesyes
Onoyes
local fieldname="email"
local fieldpath=".fields[\"$fieldname\"][0]"
bwtsv --simplify -ls wikipedia -c .name -c .username -h "$fieldname" -o "$fieldpath"

By using the JQ path $fieldpath that selects the field named "email", this example lets you copy one of the emails associated with the search string wikipedia. Any item not containing this field will not be displayed.

local fieldname="email"
local fieldpath=".fields[\"$fieldname\"] | select(length > 0) | join(\", \")"
bwtsv --simplify -pls wikipedia -c .name -c .username -h "$fieldname" -o "$fieldpath" | bw_tsv -h "$fieldname" -o '.'

Equivalent code but using piped bw_tsv to select from duplicates.

TSV Table

bwtsv --simplify -tls wikipedia .name .username -h 'num fields' '.fields | keys | length'

When using -t, instead of fzf selection, bwtsv displays all results in a TSV table.

JQ search

bwtsv --simplify -o .password ---search-pass dog --search-user frog

This command finds items with both a username containing "frog" AND password containing "dog" and copies the password to clipboard.

bwtsv --simplify -o .password -j '(.password | test("dog")) or (.username | test("frog"))'

This command finds items with either a username containing "frog" OR password containing "dog" and copies the password to clipboard.

--search-name, {--search-user, -u}, --search-pass, --search-note apply a filter to search items using case insensitive regex. {-j,--search-jq} allows a custom filter.

--simplify restructuring the items for concise queries.

Default header names

If you don't like the default header names displayed in fzf, then either edit default-headers.csv or export BW_DEFAULT_HEADERS to your file.