From 9adec53b2639d02074661a27862289a886dc0af1 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 18 Jul 2022 22:33:41 +0100 Subject: [PATCH] added passwurrd - passmenu clone --- passwurrd/passwurrd.nimble | 13 +++++++++++++ passwurrd/src/passwurrd.nim | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 passwurrd/passwurrd.nimble create mode 100644 passwurrd/src/passwurrd.nim diff --git a/passwurrd/passwurrd.nimble b/passwurrd/passwurrd.nimble new file mode 100644 index 0000000..75a497c --- /dev/null +++ b/passwurrd/passwurrd.nimble @@ -0,0 +1,13 @@ +# Package + +version = "0.1.0" +author = "Paul Wilde" +description = "A new awesome nimble package" +license = "MIT" +srcDir = "src" +bin = @["passwurrd"] + + +# Dependencies + +requires "nim >= 1.6.6" diff --git a/passwurrd/src/passwurrd.nim b/passwurrd/src/passwurrd.nim new file mode 100644 index 0000000..cd2e468 --- /dev/null +++ b/passwurrd/src/passwurrd.nim @@ -0,0 +1,28 @@ +import ../../globurrl.nim +import std/[os,osproc,re,strutils] + +const pw_store = getHomeDir() & ".password-store/" +var passwords: seq[string] = @[] +let gpg_re = re("(" & pw_store & "|\\.gpg)") +proc getPasswords(): seq[string] = + for dir in walkDir(pw_store): + if dir.kind == pcFile: + continue + for file in walkDir(dir.path): + if file.path.endsWith(".gpg"): + let pw = replace(file.path,gpg_re,"") + passwords.add(pw) + return passwords + +proc passwordToClipboard(password: string) = + discard execCmd("pass show -c " & password) + +proc main() = + var info = newInfo("Passwurrd") + var pws = getPasswords() + let output = outputData(info,pws) + if output in passwords: + passwordToClipboard(output) + +when isMainModule: + main()