Created
March 13, 2016 03:29
-
-
Save steve-ayerhart/cacf1d5701e99709b164 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
alias lstrmr=livestreamer-wrapper | |
alias twitch=twitch-wrapper | |
alias sc2=twitch-wrapper | |
twitch_sc2_endpoint='https://api.twitch.tv/kraken/streams?game=StarCraft+II&limit=10' | |
twitch_head='Accept: application/vnd.twitchtv.v3+json' | |
livestreamer-wrapper () { | |
livestreamer $1 best 1>/dev/null & | |
} | |
twitch-wrapper () { | |
livestreamer-wrapper twitch.tv/$1 | |
} | |
lsc2 () { | |
curl -sH "$twitch_head" -X GET "$twitch_sc2_endpoint" | jq '.streams[] | .channel | "\(.display_name)~~\(.status)"' | column -ts "~~" | sed 's/^"//' | sed 's/"$//' | |
} | |
_sc2() | |
{ | |
local cur prev opts | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
opts=$(curl -sH "$twitch_head" -X GET "$twitch_sc2_endpoint" | jq '.streams[] | .channel | .name' | tr '\n' ' ' | sed 's/\"//g') | |
if [[ ${cur} == * ]] ; then | |
COMPREPLY=( $(compgen -W "${opts}" ${cur}) ) | |
return 0 | |
fi | |
} | |
complete -F _sc2 sc2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment