A command-line tool for sending messages to your Twitch chat directly from your terminal.
- Send chat messages to your Twitch stream from your terminal
- Automatic authentication and token refresh
- Auto-discovery of broadcaster ID
- Easy installation and setup
- Minimal output by default, verbose mode available
- Bash shell
- curl
- A registered Twitch application (client ID and client secret)
- Make sure it's redirect URL is
http://localhost
- Make sure it's redirect URL is
Run the script once, and it will offer to install itself globally:
./twitch-chat.sh "Hello, World!"
Alternatively, use the install option:
./twitch-chat.sh --install
- Copy the script to a directory in your PATH:
cp twitch-chat.sh ~/.local/bin/twitch-chat
chmod +x ~/.local/bin/twitch-chat
- Make sure
~/.local/bin
is in your PATH:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Follow relevant steps for above as per your shell, say,
zsh
,fish
, etc.
Before using this tool, you need to create a Twitch application:
- Go to Twitch Developer Console
- Click "Register Your Application"
- Fill in the required fields:
- Name: Choose a name for your application
- OAuth Redirect URLs: Add
http://localhost
- Category: Choose "Chat Bot"
- Click "Create"
- Copy your Client ID and generate a Client Secret
Run the setup command:
twitch-chat --setup
You'll be prompted to enter:
- Your Twitch username
- Client ID
- Client Secret
twitch-chat "Hello from my terminal!"
The first time you run the script, it will guide you through the authorization process.
Usage: twitch-chat [OPTIONS] MESSAGE
Send a message to your Twitch chat from command line.
Options:
-h, --help Show this help message
-v, --verbose Verbose mode (detailed output)
--setup Configure Twitch API credentials
--install Install script globally
The script handles authentication automatically:
- First run: You'll be prompted to authorize your application
- A browser window will open with the Twitch authorization page
- After authorizing, copy the entire redirect URL back to the terminal
- The script will extract the authorization code and get access and refresh tokens
- Future runs: The script refreshes tokens automatically when needed
Your configuration is stored in:
~/.config/twitch-chat/.twitch-chat-env
- Authentication fails: Check that your client ID and secret are correct
- Token refresh fails: Try running with
--verbose
flag for more details - Browser doesn't open: Copy and paste the URL manually
Use the verbose flag to see detailed logs:
twitch-chat -v "Testing with verbose output"
This project is licensed under the MIT License - see the LICENSE file for details.