Tweet from Console is a Python-based command-line tool that lets you tweet directly from your terminal. Say goodbye to distracting web interfaces.
Good for programmers and devs who want to send tweets without leaving their console.
Happy Distraction Free Tweeting π§βπ»
python tweet.py "Your awesome tweet goes here!"This will give you a confirmation message like the following:
You sure you want to post "Your awesome tweet goes here!" ?
[ (Y)es / (N)o ] :
Type Here:Images can now be posted on X/Twitter straight from your clipboard. For this, use -c flag.
python tweet.py "Your awesome tweet goes here!" -cThis will give you a confirmation message like the following:
You sure you want to post : ---- Your awesome tweet goes here!
[Image from Clipboard] characters used: [4/ 280] ---- [ (Y)es / (N)o ] :
Type Here:
The images would be stored in the /user_media/ directory.
python tweet.py "Your awesome tweet goes here!" --This would not ask for a confirmation message. It directly posts your tweet.
python tweet.py -th
python tweet.py --tweethistory python tweet.pyRunning this simple code would allow users to send multiline tweets. This is helpful since consoles are usually limited to inline inputs.
After writing the tweet, go to new line and then type :q to exit.
Note: If you want to skip the confirmation message, just like Usage 1, execute python tweet.py --
Note: You can execute multiline tweets in a single line using the \n. The following is an example:
python tweet.py "Line 1 \nLine 2"Here is the format of the tweet that would be posted:
Line 1
Line 2
python tweet.py -e
python tweet.py --error - π Send text-based tweets from the command line
- β²οΈ Fast, simple and straight-forward
- π Secure integration with Twitter API
- πΌοΈ Image upload option from Clipboard
- π Python 3.6 or higher
- π¦ Twitter Developer Account and API keys
- Clone the repository:
- Create and activate a virtual environment:
- Install the required dependencies:
- Set up your Twitter API credentials:
- Rename
scripts/.env.exampletoscripts/.env - Open
scripts/.envand fill in your Twitter API credentials
- Rename
git clone https://github.com/yourusername/tweet-from-console.git
cd tweet-from-console
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Script\activate`
pip install -r requirements.txt- (Optional but Highly Recommended) Create aliases in your terminal configuration for quick access of
tweet.py. Following are configurations for some popular shells:
i. Bash
Add this line to ~/.bashrc:
alias tw='python /path/to/tweet.py'
- Reload with:
source ~/.bashrc - Usage:
tw [arguments]
ii. Zsh
Insert the same line in ~/.zshrc:
alias tw='python /path/to/tweet.py'
- Reload with:
source ~/.zshrc - Usage:
tw [arguments]
iii. Fish
Add this line to ~/.config/fish/config.fish:
alias tw='python /path/to/tweet.py'
-
To persist, use:
alias --save tw='python /path/to/tweet.py' -
Or, create a function for full argument support:
function tw python /path/to/tweet.py $argv end funcsave tw -
Usage:
tw [arguments]
iv. PowerShell
Define a function in your profile ($PROFILE, usually at Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1):
function tw { python C:\path\to\tweet.py @args }
- Reload profile or restart PowerShell.
- Usage:
tw [arguments]jdatascientist
- Replace
/path/to/tweet.py(Linux/macOS) orC:\path\to\tweet.py(Windows) with the actual script path. - These methods support command-line arguments and work for most CLI Python apps
- Aliases only persist after reloading the config file or opening a new terminal session
Ensure your scripts/.env file contains these Twitter API credentials:
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET_KEY=your_api_secret_key
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret
Following guides would help you get the API keys from Twitter/X Developers Platform:
Contributions are welcome! Feel free to submit a Pull Request and join our tweeting revolution! π
This tool is for educational purposes only. Always comply with Twitter's terms of service and API usage guidelines. Tweet responsibly.





