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()