I built a CLI tool that auto-copies OTPs from Gmail — no more tab switching
Source: Dev.to
Overview
Every time you need to log into a service you typically:
- Enter email and password
- Wait for the OTP email
- Switch to Gmail, find the email, copy the 6‑digit code
- Switch back and paste it before it expires
Doing this dozens of times a day adds up to a lot of wasted time. OTPilot automates the process:
- Runs silently in the background
- Press a hotkey to fetch your last 10 Gmail messages, extract the OTP, copy it to the clipboard, and show a desktop notification
- No tab switching, no waiting – just paste
Installation
pip install otpilotRequirements
- Python 3.8+
- A Gmail account
- Google Cloud project with the Gmail API enabled (free; one‑time ~5 minute setup)
Setup
Run the setup wizard to configure OTPilot:
otpilot setupThe wizard will guide you through:
- Importing your Google credentials
- One‑time Gmail sign‑in (OAuth with read‑only access)
- Setting your preferred hotkey
After setup, start the daemon:
otpilot startIt will sit in your system tray and wait for the hotkey.
Clipboard support on Linux
OTPilot uses xclip or xsel for clipboard operations. Install one of them:
sudo apt install xclip # or sudo apt install xselUsage
Press the hotkey you configured. OTPilot will:
- Fetch the latest 10 emails from Gmail
- Locate the OTP in the email body
- Copy the OTP to your clipboard
- Show a desktop notification
Security & Privacy
- Your Google credentials never leave your machine.
- Access is read‑only; OTPilot cannot send, delete, or modify any email.
- Emails are fetched only when you press the hotkey—no background polling.
- OAuth tokens are stored locally at
~/.otpilot/.
Platform Support
- macOS
- Linux (requires
xclip/xsel) - Windows
Links
- GitHub:
- Website:
License
MIT licensed. Feedback and contributions are welcome, especially for improving OTP extraction patterns, as different services format their emails differently.