Skip to content

Instantly share code, notes, and snippets.

@lukalot
Last active May 29, 2025 08:10
Show Gist options
  • Save lukalot/9493492624b6d31c8d2169f216a5d74e to your computer and use it in GitHub Desktop.
Save lukalot/9493492624b6d31c8d2169f216a5d74e to your computer and use it in GitHub Desktop.
Interface script for RBW Bitwarden Tool
#! /usr/bin/fish
# "r-bitwarden interface"
# uses rbw with fzf to make console password management easy
function rbwi -d "Easy interface script for rbw using fzf"
# get formatting codes
set bold (tput bold)
set normal (tput sgr0)
# parse input arguments
set -l options 'h/help' 'p/password' 'c/code' 'r/remove' 'e/edit' 'g/get'
argparse $options -- $argv
or return
if set -q _flag_help
echo -e "\033[1mrbwi 0.1.0\033[0m"
echo -e "Easy interface script for rbw using fzf\n"
echo -n $bold"USAGE: "; echo -e $normal"rbwi [options]\n"
echo $bold"OPTIONS "$normal"(In order of precedence)"
echo " -p or --password : select a password from your vault."
echo " -c or --code : select an auth code from your vault."
echo " -h or --help : show this help."
echo " -r or --remove : remove a selected entry from your vault."
echo " -g or --get : put the result to standard out instead of copying."
echo " -e or --edit : open the selected rbw editor to modify the entry."
else if set -q _flag_password # Get password from entry
set -l f (rbw list | fzf --header="Select entry to retreive password for")
if test "$f" != ""
if set -q _flag_get
rbw get "$f"
else
echo "password for '$f' to clipboard."
rbw get "$f" | xclip -selection clipboard
end
else
echo "entry to retrieve password for must be selected."
end
else if set -q _flag_code # Get auth code from entry
set -l f (rbw list | fzf --header="Select entry to retreive auth code for")
if test "$f" != ""
if set -q _flag_get
rbw code "$f"
else
echo "auth code for '$f' to clipboard."
rbw code "$f" | xclip -selection clipboard
end
else
echo "entry to retreive auth code from must be selected."
end
else if set -q _flag_remove # Remove entry
set -l f (rbw list | fzf --header="Select entry to remove")
if test "$f" != ""
rbw remove $f
echo "removed entry for '$f'."
else
echo "entry to remove must be selected."
end
else if set -q _flag_edit # Edit entry
set -l f (rbw list | fzf --header="Select entry to edit")
if test "$f" != ""
rbw edit $f
else
echo "entry to edit must be selected."
end
else # (DEFAULT) Print information about the entry to the console
set -l f (rbw list | fzf --header="Select entry")
if test "$f" != ""
echo "$bold'$f'$normal"
echo -n $bold"Password: "$normal; rbw get $f
echo -n $bold"Authcode: "$normal
if test "(rbw code $f)" != "rbw code: entry does not contain a totp secret"
rbw code $f
else
echo "none"
end
else
echo "an entry must be selected."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment