> 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 copy/paste sudo password from 1Password

If you get tired of typing your sudo password every time you need to run a command with sudo, or reaching for your Yubikey, you can use this complex modification to copy your sudo password from 1Password and paste it into the terminal when you hit CMD+CTRL+S.

You will need the (1Password CLI)[https://developer.1password.com/docs/cli/get-started/] 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, so your command path may need modified as well.

{
    "description": "Ctrl+Cmd+S to Paste, Submit, and CLEAR Clipboard",
    "manipulators": [
        {
            "from": {
                "key_code": "s",
                "modifiers": { "mandatory": ["left_control", "left_command"] }
            },
            "to": [{ "shell_command": "/opt/homebrew/bin/op item get "[YOUR_SECRET_UUID_HERE]" --fields password --reveal | tr -d '
' | pbcopy && afplay /System/Library/Sounds/Pop.aiff && osascript -e 'tell application "System Events" to keystroke "v" using command down' && osascript -e 'tell application "System Events" to key code 36' && sleep 1 && echo "" | pbcopy" }],
            "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.

{
    "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