A pure bash, pipe friendly, feature rich, command line interface for Slack. Richly formatted messages are a first class concept, helping you send beautiful messages with ease. Deep integration with jq allows for the ability to perform advanced operations upon JSON responses, helping you perform complex queries and pipe chaining with ease.
Basic message example:
$ slack chat send hi @slackbot
Richly formatted message example:
$ slack chat send \
--author 'author' \
--author-icon 'https://assets-cdn.github.com/images/modules/logos_page/Octocat.png' \
--author-link 'https://github.com/rockymadden/slack-cli' \
--channel '#channel' \
--color good \
--footer 'footer' \
--footer-icon 'https://assets-cdn.github.com/images/modules/logos_page/Octocat.png' \
--image 'https://assets-cdn.github.com/images/modules/logos_page/Octocat.png' \
--pretext 'pretext' \
--text 'text' \
--timestamp 123456789 \
--title 'title' \
--title-link 'https://github.com/rockymadden/slack-cli'
Pipe chaining example:
$ # Send a message, update the message, and finally delete the message:
$ slack chat send hello @slackbot --filter '.ts + "\n" + .channel' |
xargs -n2 slack chat update goodbye --filter '.ts + "\n" + .channel' |
xargs -n2 slack chat delete
$ brew tap rockymadden/rockymadden/slack-cli
$ curl -O https://raw.githubusercontent.com/rockymadden/slack-cli/master/src/slack
$ chmod +x slack
PROTIP: You are responsible for having
jq
on yourPATH
.
$ git clone [email protected]:rockymadden/slack-cli.git
$ cd slack-cli
$ make install bindir=/path/to/bin etcdir=/path/to/etc
PROTIP: You are responsible for having
jq
on yourPATH
.
Ensure you have a Slack API token and use said token one of the following ways:
$ slack init
export SLACK_CLI_TOKEN='token'
$ slack --help
Usage:
slack chat delete [<timestamp> [channel]]
[--channel|-ch <channel>] [--compact|-c] [--filter|-f <filter>] [--monochrome|-m]
[--timestamp|-ts <timestamp>] [--trace|-x]
slack chat send [<text> [channel]]
[--author|-at <author>] [--author-icon|-ai <author-icon-url>]
[--author-link|-al <author-link>] [--channel|-ch <channel>] [--color|-cl <color>]
[--compact|-cp] [--filter|-f <filter>] [--footer|-ft <footer>]
[--footer-icon|-fi <footer-icon-url>] [--image|-im <image-url>] [--monochrome|-m]
[--pretext|-pt <pretext>] [--text|-tx <text>] [--thumbnail|-th <thumbnail-url>]
[--title|-ti <title>] [--title-link|-tl <title-link>] [--trace|-x]
slack chat update [<text> [<timestamp> [channel]]]
[--author|-at <author>] [--author-icon|-ai <author-icon-url>]
[--author-link|-al <author-link>] [--channel|-ch <channel>] [--color|-cl <color>]
[--compact|-cp] [--filter|-f <filter>] [--footer|-ft <footer>]
[--footer-icon|-fi <footer-icon-url>] [--image|-im <image-url>] [--monochrome|-m]
[--pretext|-pt <pretext>] [--text|-tx <text>] [--thumbnail|-th <thumbnail-url>]
[--timestamp|-ts <timestamp>] [--title|-ti <title>] [--title-link|-tl <title-link>]
[--trace|-x]
slack init
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--token|-tk <token>]
[--trace|-x]
slack file delete [file]
[--compact|-c] [--file|-fl <file>] [--filter|-f <filter>] [--monochrome|-m]
[--trace|-x]
slack file info [file]
[--count|-cn <count>] [--compact|-c] [--file|-fl <file>] [--filter|-f <filter>]
[--monochrome|-m] [--page|-pg <page>] [--trace|-x]
slack file list
[--channel|-ch <channel>] [--count|-cn <count>] [--compact|-c] [--filter|-f <filter>]
[--monochrome|-m] [--page|-pg <page>] [--timestamp-from|-tf <timetamp>]
[--timestamp-to|-tt <timestamp>] [--trace|-x] [--types|-ty <types>]
[--user|-ur <user>]
slack file upload [<file> [channels]]
[--channels|-chs <channels>] [--comment|-cm <comment>] [--compact|-c]
[--file|fl <file>] [--filename|-fn <filename>] [--filter|-f <filter>]
[--monochrome|-m] [--title|-ti <title>] [--trace|-x]
slack presence active
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--trace|-x]
slack presence away
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--trace|-x]
slack snooze end
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--trace|-x]
slack snooze info [user]
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--trace|-x]
[--user|-ur <user>]
slack snooze start [minutes]
[--compact|-c] [--filter|-f <filter>] [--minutes|-mn <minutes>] [--monochrome|-m]
[--trace|-x]
slack status edit [<text> [<emoji>]]
[--compact|-c] [--filter|-f <filter>] [--monochrome|-m] [--trace|-x]
Configuration Commands:
init Initialize
Chat Commands:
chat delete Delete chat message
chat send Send chat message
chat update Update chat message
File Commands:
file delete Delete file
file info Info about file
file list List files
file upload Upload file
Presence Commands:
presence active Active presence
presence away Away presence
Snooze Commands:
snooze end End snooze
snooze info Info about snooze
snooze start Start snooze
Status Commands:
status edit Edit status
More Information:
repo https://github.com/rockymadden/slack-cli
PROTIPS:
- The
--compact
option is a wrapper around the jq--compact-output
option - The
--filter
option is passed directly to jq as a filter - The
--monochrome
option a wrapper around the jq--monochrome-output
option - All commands prompt for required arguments which were not provided via options or arguments. This allows for both traditional usage and prompt-based usage.
$ # Send message via prompts:
$ slack chat send
$ # Send message via arguments:
$ slack chat send 'Hello world!' '#channel'
$ # Send message via options:
$ slack chat send --text 'Hello world!' --channel '#channel'
$ # Send message via short form options:
$ slack chat send -tx 'Hello world!' -ch '#channel'
$ # Send message via pipe:
$ ls -al | slack chat send --channel '#channel' --pretext 'Directory:' --color good
$ # Send message and returning just the timestamp via filter option:
$ slack chat send 'Hello world!' '#channel' --filter '.ts'
PROTIP: See the Slack attachments documentation for more information about option meanings.
$ # Update message via prompts:
$ slack chat update
$ # Update message via arguments:
$ slack chat update 'Hello world, again!' 1405894322.002768 '#channel'
$ # Update message via options:
$ slack chat update --text 'Hello world, again!' --timestamp 1405894322.002768 --channel '#channel'
$ # Update message via short form options:
$ slack chat update -tx 'Hello world, again!' -ts 1405894322.002768 -ch '#channel'
$ # Send message and immediately update:
$ slack chat send 'Hello world!' '#channel' --filter '.ts + "\n" + .channel' |
xargs -n2 slack chat update 'Goodbye world!'
PROTIP: See the Slack attachments documentation for more information about option meanings.
$ # Delete message via prompts:
$ slack chat delete
$ # Delete message via arguments:
$ slack chat delete 1405894322.002768 '#channel'
$ # Delete message via options:
$ slack chat delete --timestamp 1405894322.002768 --channel '#channel'
$ # Delete message via short form options:
$ slack chat delete -ts 1405894322.002768 -ch '#channel'
$ # Send message and immediately delete:
$ slack chat send 'Hello world!' '#channel' --filter '.ts + "\n" + .channel' |
xargs -n2 slack chat delete
$ # Upload file via prompts:
$ slack file upload
$ # Upload file via arguments:
$ slack file upload README.md '#channel'
$ # Upload file via options:
$ slack file upload --file README.md --channels '#channel'
$ # Upload file via pipe:
$ ls -al | slack file upload --channels '#channel'
$ # Upload file with rich formatting:
$ slack file upload README.md '#channel' --comment 'Comment' --title 'Title'
$ # List files:
$ slack file list
$ # List files and output only ID and size:
$ slack file list --filter '[.files[] | {id, size}]'
$ # Info about file via prompts:
$ slack file info
$ # Info about file via arguments:
$ slack file info F2147483862
$ # Info about file via options:
$ slack file info --file F2147483862
$ # Delete file via prompts:
$ slack file delete
$ # Delete file via arguments:
$ slack file delete F2147483862
$ # Delete file via options:
$ slack file delete --file F2147483862
$ # Active presence:
$ slack presence active
$ # Away presence:
$ slack presence away
$ # Start snooze via prompts:
$ slack snooze start
$ # Start snooze via arguments:
$ slack snooze start 60
$ # Start snooze via options:
$ slack snooze start --minutes 60
$ # Start snooze via short form options:
$ slack snooze start -mn 60
$ # Info about your own snooze:
$ slack snooze info
$ # Info about another user's snooze via argument:
$ slack snooze info @slackbot
$ # Info about another user's snooze via options:
$ slack snooze info --user @slackbot
$ # Info about another user's snooze via short form options:
$ slack snooze info -ur @slackbot
$ # End snooze:
$ slack snooze end
$ # Edit status:
$ slack status edit
$ # Edit status via arguments:
$ slack status edit lunch :hamburger:
$ # Edit status via options:
$ slack status edit --text lunch --emoji :hamburger:
$ # Edit status via short form options:
$ slack status edit --tx lunch -em :hamburger:
The MIT License (MIT)
Copyright (c) 2017 Rocky Madden (https://rockymadden.com/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.