keepassxreboot / keepassxc

KeePassXC is a cross-platform community-driven port of the Windows application “Keepass Password Safe”.
https://keepassxc.org/
Other
20.98k stars 1.45k forks source link

keepassxc-cli: "show" command - Add option to display all attributes without specified in attribute -a #4383

Open mcflythekid opened 4 years ago

mcflythekid commented 4 years ago

Summary

Display all attribute in "show" command

Desired Behavior

When using show command. To dis play specified additional attribute, we need to provide the attribute name. But I need to display all data, including: username, password, title, note, extra attribute

Possible Solution

Update Show.cpp in cli source directory

Context

I have a custom command to fuzzy (Using fzf) select database entry and entry attribute to put it into clipboard. But the "show" command only show the default information (Without extra attribute). So I cannot copy the extra attributes.

#!/bin/bash
PASSWD=" "
FILE="$HOME/st/st-mini/password.kdbx"
ERRMSG="Error\n$0 <keyword>"
DIR="main"

KEYWORD=$1

if [ -z $KEYWORD ]; then echo -e $ERRMSG; exit 1; fi

SELECTED_ENTRY=$((echo "$PASSWD" | keepassxc-cli ls $FILE $DIR) | grep -i $KEYWORD | fzf)
ENTRY=$((echo "$PASSWD" | keepassxc-cli show $FILE "${DIR}/${SELECTED_ENTRY}") | sed '/Enter\spassword/d' | sed '/.*\:\s$/d' | fzf)

KEY=$(echo $ENTRY | sed 's/^\(.*\)\:\s\(.*\)$/\1/')
VAL=$(echo $ENTRY | sed 's/^\(.*\)\:\s\(.*\)$/\2/')

if [ -z $KEY ]; then exit 0; fi
if [ -z $VAL ]; then exit 0; fi

if [ $KEY == "Password" ]; then
  HELL=$(echo "$PASSWD" | keepassxc-cli clip $FILE "${DIR}/${SELECTED_ENTRY}")
  echo "$SELECTED_ENTRY's Password copied"
else
  printf $VAL | xclip -sel clip
  echo "$SELECTED_ENTRY's $KEY copied"
fi
droidmonkey commented 4 years ago

Could easily add a -a parameter

mcflythekid commented 4 years ago

Could easily add a -a parameter

-a parameter require an followed attribute.

I need to show all attributes without knowing the names.

Farzat07 commented 2 years ago

Exactly - one shouldn't have to guess what the attribute names were.

The command should show all attributes as I don't see any reason why they shouldn't be shown. Otherwise, at least an alternative command should be provided which lists all the attributes. From this list one could then get the attribute's value using the -a option.

Ferk commented 2 years ago

Also, if there was a way to show the autotype window patterns in keepassxc-cli, it would be possible to make a bash script sort of similar to that one which could work for autotype in wayland (#2281)

shukon commented 1 year ago

This would benefit from show listing attributes with field names in a key:value manner, like this comment in #6011 suggests.

lwbt commented 1 year ago

I was wondering why this issue is still open.

I after searching around a bit I thought that show --all from https://github.com/keepassxreboot/keepassxc/pull/8256 will show custom attributes, but it does not. So it is correct that this issue is still open.

My version (and also a hint how to use keepassxc-cli with the Flatpak version, which I did not know before):

$ flatpak run --command=keepassxc-cli org.keepassxc.KeePassXC --version
2.7.6