doy / rbw

unofficial bitwarden cli
https://git.tozt.net/rbw
Other
611 stars 84 forks source link

Improvements to fzf script #66

Closed mattalxndr closed 2 years ago

mattalxndr commented 2 years ago

This is a vault that the existing command would have a hard time with:

% rbw ls --fields name,user,folder
host1.com       user1
host1.com       user1   folder1
host2.com       user2   spaces in folder2

First problem is, user1 has two duplicate entries, one in a dir and one without a dir (edge case, I know):

% rbw get --folder=folder1 host1.com user1
user1pass-with-folder
% rbw get host1.com user1 
user1pass-no-folder

Since the folder is removed before rbw is called, I get the wrong entry when I choose the one in folder1:

% rbw-fzf
# Choose "folder1/host1.com/user1" in fzf
user1pass-no-folder

Second problem is, user2's login is in a folder with spaces in the name:

% rbw get --folder='spaces in folder2' host2.com user2
user2pass

When I run the existing fzf script, I get this:

  spaces
  host1.com/user1
> folder1/host1.com/user1
  3/3
> _

When I should get this:

  spaces in folder2/host2.com/user2
  host1.com/user1
> folder1/host1.com/user1
  3/3
> _

The new version I'm proposing solves both problems. It's a bit shorter as well.

One thing to note is, the fzf search results list format is a bit different than the original:

  host2.com       user2   spaces in folder2
  host1.com       user1   folder1
> host1.com       user1
  3/3
> _

I don't mind it, but you might. If you like the directory first like you had it before, you can rearrange the fzf entries by passing --with-nth=3,1,2 -d'\t' to fzf, then fiddle with the sed command.

doy commented 2 years ago

thanks for pointing out these issues! i do actually prefer the existing format, but i have fixed those two bugs in 7e5b1b1452c17ba5c5c253a6eec3ad5d076b5fa6 .