Merge pull request #309 from ryantrinkle/pass-generate-and-copy

Add XMonad.Prompt.Pass.passGenerateAndCopy
This commit is contained in:
Brent Yorgey 2019-08-10 16:45:14 -05:00 committed by GitHub
commit 65e7153874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -56,6 +56,10 @@
pass-otp (https://github.com/tadfisher/pass-otp) has been setup in the running
machine.
Added 'passGenerateAndCopyPrompt', which both generates a new password and
copies it to the clipboard. These two actions are commonly desirable to
take together, e.g. when establishing a new account.
Made password prompts traverse symlinks when gathering password names for
autocomplete.

View File

@ -46,6 +46,7 @@ module XMonad.Prompt.Pass (
passPrompt
, passOTPPrompt
, passGeneratePrompt
, passGenerateAndCopyPrompt
, passRemovePrompt
, passEditPrompt
, passTypePrompt
@ -138,6 +139,13 @@ passOTPPrompt = mkPassPrompt "Select OTP" selectOTP
passGeneratePrompt :: XPConfig -> X ()
passGeneratePrompt = mkPassPrompt "Generate password" generatePassword
-- | A prompt to generate a password for a given entry and immediately copy it
-- to the clipboard. This can be used to override an already stored entry.
-- (Beware that no confirmation is asked)
--
passGenerateAndCopyPrompt :: XPConfig -> X ()
passGenerateAndCopyPrompt = mkPassPrompt "Generate and copy password" generateAndCopyPassword
-- | A prompt to remove a password for a given entry.
-- (Beware that no confirmation is asked)
--
@ -172,6 +180,13 @@ selectOTP passLabel = spawn $ "pass otp --clip \"" ++ escapeQuote passLabel ++ "
generatePassword :: String -> X ()
generatePassword passLabel = spawn $ "pass generate --force \"" ++ escapeQuote passLabel ++ "\" 30"
-- | Generate a 30 characters password for a given entry.
-- If the entry already exists, it is updated with a new password.
-- After generating the password, it is copied to the clipboard.
--
generateAndCopyPassword :: String -> X ()
generateAndCopyPassword passLabel = spawn $ "pass generate --force -c \"" ++ escapeQuote passLabel ++ "\" 30"
-- | Remove a password stored for a given entry.
--
removePassword :: String -> X ()