added passwurrd - passmenu clone

This commit is contained in:
Paul Wilde 2022-07-18 22:33:41 +01:00
parent b32de22855
commit 9adec53b26
2 changed files with 41 additions and 0 deletions

View file

@ -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"

View file

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