Skip to main content

A small CLI tool to send tweets from your terminal.

Project description

cli-tweet

A tiny Python CLI for sending tweets/X posts from your terminal. It supports an interactive multi-line composer and a one-liner mode for quick posts.

Requirements

  • Python 3.10+
  • X (Twitter) API credentials with Read and Write permissions

Installation

Install from the project directory (or from a source checkout):

pip install .

Credentials

The tool needs four secrets:

  • TWITTER_API_KEY (API key under Consumer Key)
  • TWITTER_API_KEY_SECRET (API secret under Consumer Secret)
  • ACCESS_TOKEN (Access Token under Authentication Tokens)
  • ACCESS_TOKEN_SECRET (Access Secret under Authentication Tokens)

Where to put them:

  • Environment variables work (export TWITTER_API_KEY=..., etc.).
  • Or create a .env file at the app config path (created on first run):
    • macOS/Linux default: ~/.config/cli_tweet/.env (or $XDG_CONFIG_HOME/cli_tweet/.env if XDG_CONFIG_HOME is set).
    • You can override the directory with CLI_TWEET_CONFIG_DIR=/custom/path.

Example .env:

TWITTER_API_KEY=your_key
TWITTER_API_KEY_SECRET=your_key_secret
ACCESS_TOKEN=your_access_token
ACCESS_TOKEN_SECRET=your_access_token_secret

If any value is missing, cli_tweet will prompt for it and store it in the .env file (file permissions are tightened to user-only where possible).

How to get your X API keys

  1. Get a Developer Account: go to the X Developer Portal and sign up for a Free account.
  2. Create a Project & App: follow the prompts to create a new Project and an associated App.
  3. Set permissions (crucial):
    • Open your App settings → “User authentication settings”.
    • Select Read and Write permissions (not “Read” only).
    • Type of App: “Web App, Automated App or Bot”.
  4. Generate keys:
    • Go to the “Keys and Tokens” tab.
    • Generate these four strings and save them immediately:
      • API Key (Consumer Key)
      • API Key Secret (Consumer Secret)
      • Access Token
      • Access Token Secret
  5. Important: if you generated Access Tokens before switching to Read/Write, regenerate the Access Tokens. Permission level is baked into the token at creation time.

Usage

  • Interactive composer (multi-line):

    cli_tweet
    

    Controls inside the composer:

    • Type your tweet across multiple lines.
    • /send on an empty line sends the tweet.
    • /clear wipes the draft.
    • /quit or Ctrl+D aborts without sending.
  • One-liner:

    cli_tweet "Hello world from the terminal"
    

Notes

  • Tweets are limited to 280 characters; the interactive mode shows how many characters you have left or if you are over.
  • Errors from the X API (permissions, auth, etc.) are printed to the terminal so you can correct credentials or permissions quickly.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cli_tweet-1.0.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cli_tweet-1.0.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file cli_tweet-1.0.0.tar.gz.

File metadata

  • Download URL: cli_tweet-1.0.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for cli_tweet-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8607349db320e8becb718a86a751908fd7d876b5ee369e85b9e3030e24fdbec1
MD5 559c9a7d86fa7471ada2b5c3d93ea639
BLAKE2b-256 7d61aa2ec9e9bea07c0510840cf03625bb0507bc83392441f03d7825fb1b55e4

See more details on using hashes here.

File details

Details for the file cli_tweet-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cli_tweet-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for cli_tweet-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17645902fd6bf26441138eaf105c034a66b79b00ea609b41ca037e24fc3de35a
MD5 1773e353c0ee3becd51d2753d90a4a9d
BLAKE2b-256 4166a7fea170288234b6c5cd75eadd6cd899287fb25a6a5ea9b0325a2003daf0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page