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