My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ghtp 950B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env bash
  2. #
  3. # ghtp (GitHub Transport Protocol)
  4. #
  5. # Set all remotes in the current repo to HTTPS or SSH connection.
  6. # Useful when switching environments, using public wifi, etc.
  7. #
  8. GH_SSH="git@github\.com:"
  9. GH_HTTPS="https:\/\/github\.com\/"
  10. case "$1" in
  11. -[Hh]) TYPE=HTTPS ; MATCH="git@" ; FORMULA="$GH_SSH/$GH_HTTPS" ;;
  12. -[Ss]) TYPE=SSH ; MATCH="https:" ; FORMULA="$GH_HTTPS/$GH_SSH" ;;
  13. *)
  14. echo "Usage: `basename $0` -h | -s" 1>&2
  15. echo -e " \e[0;92m-h\e[0m to switch to HTTPS" 1>&2
  16. echo -e " \e[0;92m-s\e[0m to switch to SSH" 1>&2
  17. exit 1
  18. ;;
  19. esac
  20. which awk >/dev/null && AWK=awk
  21. which gawk >/dev/null && AWK=gawk
  22. REMOTES=$(git remote -v | egrep "\t$MATCH" | "$AWK" '{print $1 " " $2}' | sort -u | sed "s/$FORMULA/")
  23. if [[ -z $REMOTES ]]; then
  24. echo "Nothing to do." ; exit
  25. fi
  26. echo "$REMOTES" | xargs -n2 git remote set-url
  27. echo -n "Remotes set to $TYPE: "
  28. echo "$REMOTES" | "$AWK" '{printf "%s ", $1}'
  29. echo