I built a CLI tool that auto-copies OTPs from Gmail — no more tab switching

Published: (March 27, 2026 at 02:36 AM EDT)
2 min read
Source: Dev.to

Source: Dev.to

Overview

Every time you need to log into a service you typically:

  1. Enter email and password
  2. Wait for the OTP email
  3. Switch to Gmail, find the email, copy the 6‑digit code
  4. 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 otpilot

Requirements

  • 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 setup

The wizard will guide you through:

  1. Importing your Google credentials
  2. One‑time Gmail sign‑in (OAuth with read‑only access)
  3. Setting your preferred hotkey

After setup, start the daemon:

otpilot start

It 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 xsel

Usage

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
  • GitHub:
  • Website:

License

MIT licensed. Feedback and contributions are welcome, especially for improving OTP extraction patterns, as different services format their emails differently.

0 views
Back to Blog

Related posts

Read more »