Skip to content

feat: add zero-dependency password-gen-win package#226

Merged
smeech merged 2 commits into
espanso:mainfrom
kaniamutan14:feat-password-gen
May 16, 2026
Merged

feat: add zero-dependency password-gen-win package#226
smeech merged 2 commits into
espanso:mainfrom
kaniamutan14:feat-password-gen

Conversation

@kaniamutan14
Copy link
Copy Markdown
Contributor

Description

This PR introduces password-gen-win, a zero-dependency password generator specifically designed for Windows. It
generates random strings of variable lengths, pastes them, and automatically copies them to the Windows clipboard
for secondary confirmation fields.

Key Features

  • Smart Triggers: Users can define the exact length of the password directly in the trigger (e.g., :pw16,
    :pws20, :pwn06).
  • Auto-Clipboard: Uses native Set-Clipboard so the generated string is immediately available to paste again.
  • Zero Dependencies: Runs entirely on native Windows PowerShell without requiring Python or other external
    tools.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml with regex-based triggers to generate standard/secure/numeric passwords.
  • Adds end-user documentation in README.md describing trigger formats and examples.
  • Adds _manifest.yml metadata 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 use shell: 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.

Comment thread packages/password-gen-win/0.1.0/package.yml Outdated
Comment thread packages/password-gen-win/0.1.0/package.yml Outdated
Comment thread packages/password-gen-win/0.1.0/package.yml Outdated
Comment thread packages/password-gen-win/0.1.0/package.yml Outdated
Comment thread packages/password-gen-win/0.1.0/README.md Outdated
Comment thread packages/password-gen-win/0.1.0/package.yml Outdated
Comment thread packages/password-gen-win/0.1.0/package.yml Outdated
Copy link
Copy Markdown
Collaborator

@smeech smeech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: powershell

but 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.

Comment thread packages/password-gen-win/0.1.0/README.md
Copy link
Copy Markdown
Contributor Author

@kaniamutan14 kaniamutan14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kaniamutan14 kaniamutan14 requested a review from smeech May 16, 2026 15:32
Copy link
Copy Markdown
Collaborator

@smeech smeech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good. I'll trigger the merge process.

It may take a few hours to appear in the Hub website.

Thank you.

@smeech smeech merged commit 0be0eaf into espanso:main May 16, 2026
1 check passed
@kaniamutan14 kaniamutan14 deleted the feat-password-gen branch May 22, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants