Skip to content

Promptly-Technologies-LLC/X-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

X CLI

A command-line tool for posting tweets to Twitter/X from the command line.

Setup

This repo uses the uv package manager to manage dependencies. If you don't already have uv installed, you can install it with the following curl command:

curl -LsSf https://astral.sh/uv/install.sh | sh

To verify install, use:

uv --version

Consult the uv installation docs for more detailed instructions and troubleshooting.

Installation

You can install the CLI tool globally using uv:

uv tool install -U git+https://github.com/Promptly-Technologies-LLC/X-cli.git

After installation, you can use:

x-cli config
x-cli tweet --text "Hello world!"

Configuration

Getting Twitter API Credentials

Before you can use the CLI, you need to configure your Twitter API credentials. To do this, you need to sign up for a Twitter/X developer account.

In the dashboard, you will need to create an application. Make sure your application has "Read and Write" permissions. From your application's "Keys and Tokens" section in the developer dashboard, generate:

  • API Key
  • API Secret
  • Access Token
  • Access Token Secret

Setting Up Credentials

Run the configuration command to set up your credentials:

x-cli config

This will prompt you for your Twitter API credentials and store them securely in ~/.config/x-cli/config.json.

To view your current configuration (without showing secrets):

x-cli config --show

Usage

Posting Tweets

To post a tweet:

x-cli tweet --text "Your tweet content here"

To post a tweet with media:

x-cli tweet --text "Check out this image!" --media /path/to/image.jpg

To post a media-only tweet (no text):

x-cli tweet --media /path/to/image.jpg

Replying to Tweets

To reply to a tweet using its ID:

x-cli tweet --text "Great point!" --reply-to 1234567890

To reply to a tweet using its URL:

x-cli tweet --text "I agree!" --reply-to "https://x.com/user/status/1234567890"

You can also include media in replies:

x-cli tweet --text "Here's my response" --media /path/to/image.jpg --reply-to 1234567890

Getting Tweets

To retrieve tweets by ID (up to 100 at a time):

x-cli get 1234567890
x-cli get 1234567890 9876543210 --format detailed
x-cli get 1234567890 --json

Looking Up Users

To look up users by username or ID (up to 100 at a time):

x-cli user elonmusk
x-cli user @nasa @spacex
x-cli user 44196397 --by-id
x-cli user elonmusk --format detailed --fields public_metrics created_at

Help

To see all available commands:

x-cli --help

To see help for a specific command:

x-cli tweet --help
x-cli config --help
x-cli get --help
x-cli user --help

About

Very simple CLI tool for posting tweets on X

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages