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 underConsumer Key)TWITTER_API_KEY_SECRET(API secret underConsumer Secret)ACCESS_TOKEN(Access Token underAuthentication Tokens)ACCESS_TOKEN_SECRET(Access Secret underAuthentication Tokens)
Where to put them:
- Environment variables work (
export TWITTER_API_KEY=..., etc.). - Or create a
.envfile at the app config path (created on first run):- macOS/Linux default:
~/.config/cli_tweet/.env(or$XDG_CONFIG_HOME/cli_tweet/.envifXDG_CONFIG_HOMEis set). - You can override the directory with
CLI_TWEET_CONFIG_DIR=/custom/path.
- macOS/Linux default:
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
- Get a Developer Account: go to the X Developer Portal and sign up for a Free account.
- Create a Project & App: follow the prompts to create a new Project and an associated App.
- 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”.
- 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
- 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.
/sendon an empty line sends the tweet./clearwipes the draft./quitor 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8607349db320e8becb718a86a751908fd7d876b5ee369e85b9e3030e24fdbec1
|
|
| MD5 |
559c9a7d86fa7471ada2b5c3d93ea639
|
|
| BLAKE2b-256 |
7d61aa2ec9e9bea07c0510840cf03625bb0507bc83392441f03d7825fb1b55e4
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17645902fd6bf26441138eaf105c034a66b79b00ea609b41ca037e24fc3de35a
|
|
| MD5 |
1773e353c0ee3becd51d2753d90a4a9d
|
|
| BLAKE2b-256 |
4166a7fea170288234b6c5cd75eadd6cd899287fb25a6a5ea9b0325a2003daf0
|