A lightweight daemon for posting tweets from your terminal. Built with Python and systemd, it provides a simple command interface for Twitter/X API v2.
- π Post tweets directly from terminal with a simple
tcommand - π¬ Real-time feedback with tweet URL and content confirmation
- π Secure credential storage via environment variables
- π Proxy support (works in restricted regions)
- πͺΆ Minimal resource usage (0% CPU when idle)
- π§ Linux systemd integration for reliability
- Linux with systemd (tested on Manjaro Linux)
- Python 3.9+
- Poetry (for dependency management)
- Twitter Developer Account with API access
# Clone the repository
git clone https://github.com/yourusername/twitter-cli
cd twitter-cli
# Install dependencies
poetry install
# Set up your Twitter API credentials
cp .env.example .env
nano .env # Add your credentials
# Install the daemon
./install.sh
# Start the service
systemctl --user start twitter-cli
systemctl --user enable twitter-cli
# Send your first tweet!
t Hello Twitter from my terminal!- Go to developer.twitter.com
- Click "Sign up" for a developer account
- Choose "Hobbyist" β "Making a bot"
- Fill in the required information about your use case
- Verify your email address
- In the Developer Portal, click "Projects & Apps"
- Click "New Project"
- Name your project (e.g., "Personal Twitter CLI")
- Choose your use case (e.g., "Making a bot")
- Inside your project, click "Create App"
- Choose a unique app name (e.g., "yourname-cli-bot")
- Save the API Key and API Key Secret shown (you'll need these!)
- Go to your app settings
- Click "User authentication settings" β "Set up"
- Enable OAuth 1.0a
- Under "App permissions", select "Read and write"
- Set Callback URI to:
http://localhost:3000 - Set Website URL to:
https://example.com - Save settings
- Go to "Keys and tokens" tab
- Under "Authentication Tokens", click "Generate" for Access Token and Secret
- Save all 4 credentials:
- API Key (Consumer Key)
- API Key Secret (Consumer Secret)
- Access Token
- Access Token Secret
Note: Free tier allows 500 tweets per month. If you get "403 Forbidden" errors, make sure you've set "Read and write" permissions and regenerated your Access Tokens after changing permissions.
# Install Poetry if you haven't already
curl -sSL https://install.python-poetry.org | python3 -
# Install project dependencies
poetry installcp .env.example .env
nano .envAdd your Twitter API credentials to the .env file.
./install.shThis will:
- Copy the
tcommand to/usr/local/bin - Set up the systemd user service
- Configure proper permissions
systemctl --user daemon-reload
systemctl --user enable twitter-cli
systemctl --user start twitter-clit Hello world from Linux terminal!You'll see:
β
Tweet published!
π Text: Hello world from Linux terminal!
π Link: https://twitter.com/yourusername/status/1234567890
t statust stop
# or
systemctl --user stop twitter-cli# Service logs
journalctl --user -u twitter-cli -f
# Application logs
tail -f twitter-daemon.logTo properly handle special characters (!,*,?), add this alias to your ~/.zshrc:
alias t="noglob t"If you're in a region where Twitter is blocked, the daemon supports proxychains. Edit the systemd service file:
nano ~/.config/systemd/user/twitter-cli.serviceAnd modify ExecStart to include proxychains:
ExecStart=/usr/bin/proxychains -q /path/to/poetry run python /path/to/twitter-daemon.py
The system consists of two main components:
- Daemon (
twitter-daemon.py): Runs as a systemd service, listens for commands via named pipe - Client (
t): Simple bash script that sends commands to the daemon
Communication happens through named pipes:
/tmp/twitter-cli-pipe- for sending commands/tmp/twitter-cli-response- for receiving responses
Check the logs:
journalctl --user -u twitter-cli -n 50Common issues:
- Invalid API credentials
- Missing dependencies
- Permission issues
Your app needs "Read and write" permissions:
- Go to Twitter Developer Portal
- Edit your app's User authentication settings
- Set permissions to "Read and write"
- Regenerate your Access Token and Secret
- Update
.envand restart the daemon
sudo cp t /usr/local/bin/t
sudo chmod +x /usr/local/bin/t# Stop and disable the service
systemctl --user stop twitter-cli
systemctl --user disable twitter-cli
# Remove files
rm ~/.config/systemd/user/twitter-cli.service
sudo rm /usr/local/bin/t- API credentials are stored in
.envfile (not in version control) - Named pipes have 666 permissions (any local user can send commands)
- Consider adjusting permissions based on your security requirements
Pull requests are welcome! Please feel free to submit issues and enhancement requests.
MIT License - see LICENSE file for details
Built with Claude Code in 20 minutes! π