Skip to content

aditya-an1l/tweet-from-console

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Logo

Tweet - From - Console

🐦 Send X / Tweets right from your terminal 🐦


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 πŸ§‘β€πŸ’»


🎞️ Preview

1. Tweet with Confirmation Message πŸ””

without confirmation

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:

2. Tweet with Image (NEW) πŸ””

with image

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!" -c

This 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.

3. Tweet without Confirmation Message ⏩

without confirmation

python tweet.py "Your awesome tweet goes here!" --

This would not ask for a confirmation message. It directly posts your tweet.

4. View Tweet History πŸ“

tweet history

python tweet.py -th 
python tweet.py --tweethistory 

5. Multi Line Tweet πŸ“œ

multiline

python tweet.py

Running 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:

inline multiline

python tweet.py "Line 1 \nLine 2"

Here is the format of the tweet that would be posted:

Line 1
Line 2  

6. View Error Logs ⚠️

python tweet.py -e 
python tweet.py --error 

✨ Features

  • πŸ“ Send text-based tweets from the command line
  • ⏲️ Fast, simple and straight-forward
  • πŸ”‘ Secure integration with Twitter API
  • πŸ–ΌοΈ Image upload option from Clipboard

πŸ› οΈ Prerequisites

  • 🐍 Python 3.6 or higher
  • 🐦 Twitter Developer Account and API keys

πŸš€ Installation

  1. Clone the repository:
  2. git clone https://github.com/yourusername/tweet-from-console.git
    cd tweet-from-console
      
  3. Create and activate a virtual environment:
  4. python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Script\activate`
      
  5. Install the required dependencies:
  6. pip install -r requirements.txt
  7. Set up your Twitter API credentials:
    • Rename scripts/.env.example to scripts/.env
    • Open scripts/.env and fill in your Twitter API credentials
  1. (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

Additional Notes

  • Replace /path/to/tweet.py (Linux/macOS) or C:\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

βš™οΈ API key configuration guide

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

How to get the API keys?

Following guides would help you get the API keys from Twitter/X Developers Platform:

🀝 Contributing

Contributions are welcome! Feel free to submit a Pull Request and join our tweeting revolution! 🌟

⚠️ Disclaimer

This tool is for educational purposes only. Always comply with Twitter's terms of service and API usage guidelines. Tweet responsibly.

About

Send tweets right from your terminal

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages