feat: add zero-dependency password-gen-win package#226
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Espanso Hub package (password-gen-win) that generates random passwords on Windows using native PowerShell and copies the generated value to the Windows clipboard.
Changes:
- Introduces
packages/password-gen-win/0.1.0/package.ymlwith regex-based triggers to generate standard/secure/numeric passwords. - Adds end-user documentation in
README.mddescribing trigger formats and examples. - Adds
_manifest.ymlmetadata for Hub indexing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| packages/password-gen-win/0.1.0/package.yml | Defines PowerShell-based generators and trigger regexes, including clipboard copying behavior. |
| packages/password-gen-win/0.1.0/README.md | Documents triggers, examples, installation, and requirements. |
| packages/password-gen-win/0.1.0/_manifest.yml | Adds Hub metadata (name/title/description/version/tags). |
Comments suppressed due to low confidence (1)
packages/password-gen-win/0.1.0/package.yml:60
- For PowerShell shell vars, other packages in this repo either omit
shell:(letting Espanso pick the platform default) or explicitly useshell: pwsh(PowerShell Core). Consider aligning with one of those patterns to avoid relying on a repo-atypical shell identifier.
Set-Clipboard -Value $pw;
Write-Output $pw
shell: powershell
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Three regex: triggers, calling essentially the same Powershell code with different variable strings for the password contents. We are particularly careful with triggers relying on scripts or shell commands so I spent a while considering it.
The code is somewhat repetitive so I did rewrite it using Espanso global variables for the character strings, concatenated by echo extension, and fed to a script referenced by a single anchor & alias, which was neater, but even longer because of the echo instances, which are not really suitable for reducing to one-liners because of the length of the strings.
Of course one could roll it into one trigger, and allow Powershell to handle the different inputs, e.g.:
- regex: ':pw(?P<mode>s|n|)(?P<len>\d{2})'
replace: "{{output}}"
vars:
- name: output
type: shell
params:
cmd: |
$mode = '{{mode}}'
$chars = switch ($mode) {
's' { 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[]{}|;:,.<>?' }
'n' { '0123456789' }
default { 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' }
}
$len = [int]('{{len}}')
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$bytes = New-Object byte[] $len
$rng.GetBytes($bytes)
$pw = -join ($bytes | ForEach-Object { $chars[$_ % $chars.Length] })
$rng.Dispose()
Set-Clipboard -Value $pw
Write-Output $pw
shell: powershellbut I'll leave it to you.
I've run Copilot, which has some suggestions too, and I'll run the automated checks to make sure it will merge without problems. Let me know when you're ready to merge, whether or not you choose to make amendments.
kaniamutan14
left a comment
There was a problem hiding this comment.
I updated the readme to include for linux and macos using pwsh and updated to your version which was awesome and fixed the modulo bias.
smeech
left a comment
There was a problem hiding this comment.
That looks good. I'll trigger the merge process.
It may take a few hours to appear in the Hub website.
Thank you.
Description
This PR introduces
password-gen-win, a zero-dependency password generator specifically designed for Windows. Itgenerates random strings of variable lengths, pastes them, and automatically copies them to the Windows clipboard
for secondary confirmation fields.
Key Features
:pw16,:pws20,:pwn06).Set-Clipboardso the generated string is immediately available to paste again.tools.