#!/bin/sh
#
## Adds a remote for the current repository for the given GitHub username.
## Source: git-extra-commands

# Source: https://github.com/rtomayko/dotfiles/blob/rtomayko/bin/git-grab

[ $# -eq 0 ] && {
  echo "usage: git-add-username-remote username [repo]"
  exit 1
}

username="$1"

if [ -n "$2" ] ; then
  repo="$2"
else
  # shellcheck disable=SC2046
  repo=$(basename $(pwd))
fi

command="git remote add $username git://github.com/$username/$repo.git"
echo "$command"
$command

command="git fetch $username"
echo "$command"
$command
