Run a command; post it and its standard input, output, and error to Slack
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Makefile
README.md
screenshot-attach.png
screenshot-hello-world.png
screenshot-stdin.png
slack.sh

README.md

slack

Run a command; post it and its standard input, output, and error to Slack. It's a tool for people that collaborate on UNIX servers.

Installation

First, install slack.sh as /usr/local/bin/slack:

sudo make install

Next, visit https://my.slack.com/services/new and create a new Incoming Webhook. Copy Your Unique Webhook URL and put it in your shell's environment:

export SLACK_WEBHOOK_URL="https://TEAM.slack.com/services/hooks/incoming-webhook?token=TOKEN"

Put this in your shell's ~/.profile or similar and make sure you source that file with . ~/.profile before you run slack.

Usage

slack will post the command-line plus standard output and standard error to Slack:

slack echo "Hello, world."

screenshot

It will also capture standard input if you tell it to:

slack --stdin mysql <"backfill.sql"

screenshot

If you like, the output can be made into a nice pretty Slack attachment:

slack --attach echo "Hello, world."

screenshot

And of course, you can point it at any channel, not just the one you configure as the default:

slack --channel="#general" echo "Hello, world."