Skip to content

Instantly share code, notes, and snippets.

@dcluna
Forked from marcosnils/tmate.sh
Created May 17, 2016 20:29
Show Gist options
  • Save dcluna/03f413524f0a23f91ac3224a47df4d6c to your computer and use it in GitHub Desktop.
Save dcluna/03f413524f0a23f91ac3224a47df4d6c to your computer and use it in GitHub Desktop.

Revisions

  1. @marcosnils marcosnils created this gist Feb 1, 2015.
    18 changes: 18 additions & 0 deletions tmate.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/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