#!/usr/bin/env nix-shell
    #! nix-shell -i bash -p wayclip rage
    
    echo $(waypaste) | rage --encrypt -a -r $AGE_PUBLIC_KEY | waycopy

I just learned that the old and very unwieldy GPG finally has a serious CLI contender in Rage and I’m soo happy about that. I’m really liking the API.

The above script is a oneliner tool to encrypt the clipboard content to a public key (your own) present as an environment variable (because you set it). If you are not on NixOS, you can skip the elaborate she-bang and manually install the wayclip (or similar clipboard-handling for your system) and rage packages (like its ‘99) and then:

    #!/usr/bin/env bash

    echo $(waypaste) | rage --encrypt -a -r $AGE_PUBLIC_KEY | waycopy

Assign it to a hotkey and now you can copy-encrypt-paste a section of text in-place while writing it (and before saving it).