diff --git a/README.md b/README.md index 77aaeeb..17e7f04 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Launches fzf in the terminal with fuzzy matching. Recently used entries appear a | Flag | Description | Default | |--------------------------|--------------------------------------|------------| | `--selector rofi\|fzf` | Which selector UI to use | `rofi` | -| `--field password\|username\|totp` | Which field to retrieve (fzf / history) | `password` | +| `--field password\|username\|totp\|name` | Which field to retrieve (fzf / history) | `password` | | `--print` | Print to stdout instead of clipboard | off | The selected field is copied to the clipboard using `wl-copy` (Wayland) or `xclip` (X11). When `--print` is passed, the value is printed to stdout instead. diff --git a/src/bw_menu/cli.py b/src/bw_menu/cli.py index cb824ee..5f209fa 100644 --- a/src/bw_menu/cli.py +++ b/src/bw_menu/cli.py @@ -13,7 +13,7 @@ def parse_args(): select_parser = subparsers.add_parser("select") select_parser.add_argument("--selector", default="rofi", choices=["rofi", "fzf"]) select_parser.add_argument( - "--field", default="password", choices=["username", "password", "totp"] + "--field", default="password", choices=["username", "password", "totp", "name"] ) select_parser.add_argument("--print", dest="print_result", action="store_true") # rofi script-mode passes the selected title as a positional arg — accept and ignore it @@ -28,7 +28,7 @@ def parse_args(): get_parser = history_sub.add_parser("get") get_parser.add_argument("index", type=int) get_parser.add_argument( - "--field", default="password", choices=["username", "password", "totp"] + "--field", default="password", choices=["username", "password", "totp", "name"] ) get_parser.add_argument("--print", dest="print_result", action="store_true") diff --git a/src/bw_menu/config.py b/src/bw_menu/config.py index 61d855e..7da93e6 100644 --- a/src/bw_menu/config.py +++ b/src/bw_menu/config.py @@ -11,7 +11,7 @@ DEFAULT_KEYBINDINGS = { "username": "Control+Return", "totp": "Shift+Return", } -VALID_FIELDS = {"password", "username", "totp"} +VALID_FIELDS = {"password", "username", "totp", "name"} @dataclass diff --git a/src/bw_menu/rbw.py b/src/bw_menu/rbw.py index b9544ac..310c5d4 100644 --- a/src/bw_menu/rbw.py +++ b/src/bw_menu/rbw.py @@ -33,6 +33,8 @@ def list_entries() -> list[Entry]: def get_field(entry: Entry, field: str) -> str: + if field == "name": + return entry.name if field == "totp": return __get_totp(entry) if field == "username":