Skip to content

Instantly share code, notes, and snippets.

@kliph
Created September 8, 2016 18:40
Show Gist options
  • Save kliph/2621968298cbf48923bd0056d283b195 to your computer and use it in GitHub Desktop.
Save kliph/2621968298cbf48923bd0056d283b195 to your computer and use it in GitHub Desktop.
script for publishing tmate sessions to slack
#!/bin/bash
set -e
SLACK_WEBHOOK_URL=https://wtf.bbq
DEFAULT_EMOJI=:robot_face:
CHANNEL=${1:-#remote}
AUTHOR="tmate"
tmate -S /tmp/tmate.sock new-session -d && tmate -S /tmp/tmate.sock wait tmate-ready
TMATE_URL=`tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}'`
PAYLOAD='payload={"channel": "'$CHANNEL'", "username": "'$AUTHOR'", "text": "I have setup a new tmate session for you to join. Here is the url: '$TMATE_URL'", "icon_emoji": "'$DEFAULT_EMOJI'"}'
curl -sS -o /dev/null -X POST --data-urlencode "$PAYLOAD" $SLACK_WEBHOOK_URL
tmate -S /tmp/tmate.sock attach
@kliph
Copy link
Author

kliph commented Sep 13, 2016

It would be nice to extend this to take an argument to close down the current tmate session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment