> BLOG/POSTS/USING KARABINER ELEMENTS FOR SUDO AUTHENTICATION VIA 1PASSWORD
← Back to blog (or backspace)

Using Karabiner-Elements For Sudo Authentication via 1Password

Feb 18 2026

And other complex modification (macro) scripts that I have developed

Karabiner-Elements is an incredible free tool for customizing your keyboard, mouse, and other input devices on macOS. Its most powerful feature is the ability to create complex modification (macro) scripts that can perform a variety of actions when a key — or a combination of keys — are pressed.

I’m going to share the scripts I’ve written here and I will try to remember to edit this post as I develop more scripts in the future.

CMD+CTRL+S to send sudo password from 1Password

If you get tired of typing — or copy/pasting — your sudo password every time you need to run a command, or reaching for your Yubikey, you can use this complex modification to copy your sudo password from 1Password and send the characters as keystrokes when you hit CMD+CTRL+S. Keystroke injection via Karabiner-Elements doesn’t overwrite your clipboard like copy/pasting does and it also keeps youe sudo password out of clipboard history, which is a nice bonus.

You will need the 1Password CLI tool installed and configured for this to work. Follow the instructions from the link to do that.

Then click “Complex Modifications -> Add your own rule” in the Karabiner-Elements interface.

Paste in the code below, making sure replace [YOUR_SECRET_UUID_HERE] with your actual secret UUID. To get the UUID, right click on the secret in 1Password and select “Copy UUID” (it will be a long string of letters and numbers). Also, I have installed the 1Password CLI via homebrew on a Mac, so your command path may need modified as well.

https://gist.github.com/jesse-id/0a287c4bd039ce3bf48f222f4ef73e46

{
    "description": "Ctrl+Cmd+S to retrieve 1Password secret and send as keystrokes",
    "manipulators": [
        {
            "from": {
                "key_code": "s",
                "modifiers": { "mandatory": ["left_control", "left_command"] }
            },
            "to": [
                {
                    "shell_command": "afplay /System/Library/Sounds/Pop.aiff & if SECRET=$(/opt/homebrew/bin/op item get "[YOUR_SECRET_UUID_HERE]" --fields password --reveal 2>/dev/null | tr -d '\n'); then osascript -e 'on run args' -e 'tell application "System Events" to keystroke (item 1 of args)' -e 'end run' "$SECRET" && osascript -e 'tell application "System Events" to key code 36'; fi"
                }
            ],
            "type": "basic"
        }
    ]
}

SHIFT+CTRL+OPT+CMD on hold, CMD+/ on tap

HyperKey is an app that turns CAPS LOCK into a new modifier key by sending SHIFT+CONTROL+OPTION+COMMAND when pressed and held, and escape when tapped. I have replaced it with a Karabiner-Elements complex modification script that replicates the same functionality, but sends COMMAND+/ when tapped instead. That allows me to use CAPS LOCK to quickly comment/uncomment code in my IDE as well.

Click “Complex Modifications -> Add your own rule” in the Karabiner-Elements interface.

Paste in the code below.

https://gist.github.com/jesse-id/36ec252467c20fb84fa6b6dfe5b3e604

{
    "description": "Caps Lock to Hyper Key (Held), Cmd+/ (Tapped)",
    "manipulators": [
        {
            "from": {
                "key_code": "caps_lock",
                "modifiers": { "optional": ["any"] }
            },
            "to": [
                {
                    "key_code": "left_shift",
                    "modifiers": ["left_command", "left_control", "left_option"]
                }
            ],
            "to_if_alone": [
                {
                    "key_code": "slash",
                    "modifiers": ["left_command"]
                }
            ],
            "type": "basic"
        }
    ]
}
> Loading comments...
> JESSE.ID
© 2026 All rights reserved by 👍👍 This Guy