pass_typer: Match passwords of form username@server
This commit is contained in:
parent
b45d217366
commit
af00393233
@ -4,6 +4,7 @@ import os
|
||||
import re
|
||||
import subprocess
|
||||
from functools import partial
|
||||
from itertools import chain
|
||||
from pathlib import PosixPath
|
||||
|
||||
PASSWORD_STORE = PosixPath(
|
||||
@ -33,9 +34,10 @@ def get_password(password_name: str) -> None:
|
||||
return password
|
||||
|
||||
|
||||
def select_and_type(glob: str) -> None:
|
||||
files = PASSWORD_STORE.glob(glob)
|
||||
file_list = [str(f.relative_to(PASSWORD_STORE).with_suffix("")) for f in files]
|
||||
def select_and_type(server_name: str) -> None:
|
||||
files = chain(PASSWORD_STORE.glob(f"servers/**/{server_name}.gpg"),
|
||||
PASSWORD_STORE.glob(f"servers/**/*@{server_name}.gpg"))
|
||||
file_list = {str(f.relative_to(PASSWORD_STORE).with_suffix("")) for f in files}
|
||||
|
||||
selected = rofi_select(file_list)
|
||||
password = get_password(selected)
|
||||
@ -52,7 +54,7 @@ if ssh_match:
|
||||
|
||||
notify(f"Matched server '{server_name}'", f"Window name: {window_name}")
|
||||
|
||||
select_and_type(f"servers/**/{server_name}.gpg")
|
||||
select_and_type(server_name)
|
||||
|
||||
else:
|
||||
notify("Window name did not match any rules", f"Window name: {window_name}")
|
||||
|
Loading…
Reference in New Issue
Block a user