Skip to content

Instantly share code, notes, and snippets.

@Alexander-Prime
Created September 25, 2016 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alexander-Prime/90daf3b0d4ad3846bdc8d90b71235bf2 to your computer and use it in GitHub Desktop.
Save Alexander-Prime/90daf3b0d4ad3846bdc8d90b71235bf2 to your computer and use it in GitHub Desktop.
A nice command-line utility for Linux livestreamers
#!/bin/bash
##--------------------------------------------------------------------------------
read -rd '' USAGE <<"BOUND"
Usage: strim <command>
Commands:
repo Show the current directory's Github remote on this user's overlay
tag Add a tag for this commit with the name "stream-<date>", where <date> is the current date as [yyyymmdd]
BOUND
##--------------------------------------------------------------------------------
case $1 in
## Show the current repository on this user's overlay
"repo")
LOCAL_USER=`whoami`
REMOTE_ADDR="192.168.1.145"
REMOTE_FILE="/home/stream/Dev/scenes/$LOCAL_USER-repo.txt"
RESULTS=`git remote -v 2>/dev/null | egrep "github.*\(push\)$"`
if [[ $RESULTS =~ github\.com:([^\.]+)\.git ]]
then
REPO="https://github.com/${BASH_REMATCH[1]}"
echo "Setting repository URL..."
echo -e "\t$LOCAL_USER -> \e[1;92m$REPO\e[0m\n"
else
REPO="No Github repository for this project"
echo "Not in a repository"
echo -e "\t$LOCAL_USER -> \e[1;91m[none]\e[0m\n"
fi
echo -n $REPO | ssh stream@$REMOTE_ADDR "cat > $REMOTE_FILE"
;;
## Tag the current repository with the date (eg "stream-20160930")
"tag")
git tag -a stream-`date +%Y%m%d`
;;
*)
echo -e "$USAGE"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment