• Stars
    star
    1,053
  • Rank 43,788 (Top 0.9 %)
  • Language
    Shell
  • Created about 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

:neckbeard: Powerful Slack CLI via pure bash. Rich messaging, uploads, posts, piping, oh my!

slack-cli | Powerful Slack CLI via pure bash

version versioning branching license circleci

A pure bash, pipe friendly, feature rich, command line interface for Slack. Richly formatted messages, file uploads, and even creating Slack posts are first class constructs. 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.

Simple chat example:

$ slack chat send hi @slackbot

100% Slack-based pomodoro example:

$ alias pomodoro='f() { slack status edit --text="Pomodoro" --emoji=":tomato:" && slack snooze start --minutes="${1-60}" && slack reminder add "Pomodoro done!" $(date -v +${1-60}M "+%s") }; f'
$ pomodoro 60

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

Richly formatted chat example:

$ slack chat send \
  --actions '{"type": "button", "style": "primary", "text": "See results", "url": "http://example.com"}' \
  --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 \
  --fields '{"title": "Environment", "value": "snapshot", "short": true}' \
  --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' \
  --time 123456789 \
  --title 'title' \
  --title-link 'https://github.com/rockymadden/slack-cli'

Installation

Via brew

$ brew tap rockymadden/rockymadden
$ brew install rockymadden/rockymadden/slack-cli

Via curl

$ curl -O https://raw.githubusercontent.com/rockymadden/slack-cli/master/src/slack
$ chmod +x slack

PROTIP: You are responsible for having curl and jq on your PATH.

Via make

$ 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 curl and jq on your PATH.

Configuration

If you want to post from your own account, you need a legacy API token which can be found here. If you want to post from a slackbot, create one here. Otherwise, you can create an app with a Slack API token and use said API token one of the following ways:

Via init

$ slack init

Via environment variable

$ export SLACK_CLI_TOKEN='token'

Examples and Recipes

chat send

$ # 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.

chat update

$ # 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.

chat delete

$ # 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

file upload

$ # 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'
$
$ # Create a Slack post, noting the filetype option:
$ slack file upload --file post.md --filetype post --title 'Post Title' --channels '#channel'

file list

$ # List files:
$ slack file list
$
$ # List files and output only ID and size:
$ slack file list --filter '[.files[] | {id, size}]'

file info

$ # 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

file delete

$ # Delete file via prompts:
$ slack file delete
$
$ # Delete file via arguments:
$ slack file delete F2147483862
$
$ # Delete file via options:
$ slack file delete --file F2147483862

presence active

$ # Active presence:
$ slack presence active

reminder list

$ # List reminders:
$ slack reminder list

reminder add

$ # Add reminder via prompts:
$ slack reminder add
$
$ # Add reminder via arguments:
$ slack reminder add 'lunch' 1526995300
$
$ # Add reminder in 10 minutes, via date on macOS, via arguments:
$ slack reminder add 'lunch' $(date -v +10M "+%s")
$
$ # Add reminder via options:
$ slack reminder add --text="lunch" --time=1526995300

reminder complete

$ # Complete reminder via prompts:
$ slack reminder complete
$
$ # Complete reminder via arguments:
$ slack reminder complete Rm7MGABKT6
$
$ # Complete reminder via options:
$ slack reminder complete --reminder="Rm7MGABKT6"

reminder delete

$ # Complete reminder via prompts:
$ slack reminder delete
$
$ # Complete reminder via arguments:
$ slack reminder delete "Rm7MGABKT6"
$
$ # Complete reminder via options:
$ slack reminder delete --reminder="Rm7MGABKT6"

reminder info

$ # Info about reminder via prompts:
$ slack reminder info
$
$ # Info about reminder via arguments:
$ slack reminder info "Rm7MGABKT6"
$
$ # Info about reminder via options:
$ slack reminder info --reminder="Rm7MGABKT6"

presence away

$ # Away presence:
$ slack presence away

snooze start

$ # 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

snooze info

$ # 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

snooze end

$ # End snooze:
$ slack snooze end

status edit

$ # 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:

Contributors

A big thank you to the following contributors who have helped add features and/or fixes:

License

The MIT License (MIT)

Copyright (c) 2018 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.

More Repositories

1

stringmetric

🎯 String metrics and phonetic algorithms for Scala (e.g. Dice/Sorensen, Hamming, Jaccard, Jaro, Jaro-Winkler, Levenshtein, Metaphone, N-Gram, NYSIIS, Overlap, Ratcliff/Obershelp, Refined NYSIIS, Refined Soundex, Soundex, Weighted Levenshtein).
Scala
485
star
2

somafm-cli

🎵 Listen to SomaFM in your terminal via pure bash
Shell
139
star
3

gap

🔩 Fix default Google Analytics tracking methodologies and track micro user behaviors.
CoffeeScript
81
star
4

circleci-cli

🚦 Powerful CircleCI CLI via pure bash
Shell
76
star
5

scala-node

🔗 Proof of concept to determine if Scala.js could be leveraged to make a Node.js module. It can.
CoffeeScript
55
star
6

canvas-lms-cloud

☁️ Automagically configure, deploy, and host the open source Canvas LMS on everything from simple local virtual machine instance to a horizontally scaling, fault-tolerant, load balanced private cloud.
Shell
50
star
7

transfer-cli

🚡 Powerful transfer.sh CLI via pure bash
Shell
29
star
8

lti.js

🎓 Learning Tools Interoperability Node library.
CoffeeScript
17
star
9

github-crypt

:octocat: Send encrypted messages to GitHubers via their SSH public key
Shell
15
star
10

delimited

🚀 Simple CSV I/O for Scala. Read, write, validate, and transform. Do so line-by-line, all-at-once, or via streams.
Scala
11
star
11

droplr.sh

🎉 Upload files to Droplr via the command line.
Shell
11
star
12

tomorrow-night-eighties-syntax-theme

Atom syntax theme using the ever popular Tomorrow Night Eighties colors.
CSS
9
star
13

dotfiles

:neckbeard: Personal dotfiles
Vim Script
6
star
14

canvas-lms.js

Functional Node wrapper for the open source Canvas LMS REST API.
CoffeeScript
5
star
15

algs1

Algorithms, Part I
Java
2
star
16

leetcode

Java
1
star
17

react-github-repos

:octocat: React GitHub repos component with a high degree of customizability.
JavaScript
1
star
18

dotfiles-ubuntu

:neckbeard: Personal dotfiles for ubuntu server
Shell
1
star
19

homebrew-dotfiles

🍺 dotfiles management via homebrew
Shell
1
star
20

algs1-queues

Java
1
star