#!/usr/bin/env fish # This script lets you query entries from bitwarden # using rbw and fuzzel. You can copy, auto-type, or show in notification. # Requires wl-copy, wtype, jq, and rbw. set -l action if test (count $argv) -ne 0 set action $argv[1] else set action (echo copy\ntype\nshow | fuzzel --prompt="Action> " --dmenu) end set -l query set -l queries username password code if test "$action" = type set --append queries double end set query (string join \n $queries | fuzzel --prompt="Query> " --dmenu) if test -z "$query" return 1 end set -l selected (rbw list | fuzzel --prompt="$query: " --dmenu) if test -z "$selected" return 1 end set -l output if test "$query" = code set output (rbw code "$selected") else if test "$query" = double for i in username password set --append output (rbw get "$selected" --raw | jq --join-output ".data.$i") end else set output (rbw get "$selected" --raw | jq --join-output ".data.$query") end switch $action case copy wl-copy $output case type if test (count $output) -eq 1 wtype "$output" else wtype "$output[1]" wtype -k Tab wtype "$output[2]" end case show notify-send --wait "$output" case '*' notify-send "Invalid command!" end