Skip to content

Instantly share code, notes, and snippets.

@marcosnils
Created February 1, 2015 19:30
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save marcosnils/a1734c447728f3a37739 to your computer and use it in GitHub Desktop.
Save marcosnils/a1734c447728f3a37739 to your computer and use it in GitHub Desktop.
Tmate slack
#!/bin/bash
set -e
SLACK_WEBHOOK_URL=
DEFAULT_EMOJI=:slack:
CHANNEL=${1:-#general}
AUTHOR="Some user"
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
@marcosnils
Copy link
Author

Add the incoming webhook integration into your slack tema account and paste the url into the SLACK_WEBHOOK_URL variable.

Enjoy!

@mostlycoolmark
Copy link

Thanks for creating this, @marcosnils!

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