x-cli
A command-line tool for viewing X (Twitter) posts and their replies.
Installation
npm install -g x-cli
Or clone and link locally:
git clone https://github.com/yourusername/x-cli.git
cd x-cli
npm install
npm run build
npm link
Authentication
The CLI requires your X session cookies. To set up:
- Open x.com in your browser and log in
- Open DevTools (F12) → Application → Cookies → x.com
- Copy the values for
auth_token and ct0
- Create the config file:
mkdir -p ~/.config/x-cli
cat > ~/.config/x-cli/cookies.txt << EOF
auth_token=YOUR_AUTH_TOKEN
ct0=YOUR_CT0_TOKEN
EOF
Usage
x tweet https://x.com/user/status/1234567890
x tweet https://x.com/user/status/1234567890 --pretty
x tweet 1234567890
Output
JSON (default)
{
"mainTweet": {
"id": "1234567890",
"text": "Hello world!",
"author": { "name": "User", "username": "user" },
"metrics": { "likes": 10, "retweets": 5, "replies": 2 }
},
"parentTweets": [],
"replies": [...]
}
Pretty (--pretty)
User @username 2h ago
Hello world!
2 replies 5 retweets 10 likes 1.2K views
--- Replies (2) ---
Reply Author @reply_user 1h ago
Nice post!
Shell Completions
The easiest way to install shell completions is to run:
x setup
This auto-detects your shell and installs completions to the appropriate location.
Manual Installation
If you prefer to install manually:
x completion bash >> ~/.bashrc
mkdir -p ~/.zsh/completions
x completion zsh > ~/.zsh/completions/_x
x completion fish > ~/.config/fish/completions/x.fish
License
MIT