Skip to content

Instantly share code, notes, and snippets.

@Kehet
Created April 8, 2021 21:16
Show Gist options
  • Select an option

  • Save Kehet/fd0f7db37d4da534b64bf77c17467b69 to your computer and use it in GitHub Desktop.

Select an option

Save Kehet/fd0f7db37d4da534b64bf77c17467b69 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -eq 0 ] ; then
echo "USAGE: ${0} URL"
exit 1
fi
URL="$1"
if [ "$URL" = "${URL##https:\/\/}" ]; then
IFS=':'
read -r FOLDER URL <<< "$URL"
FOLDER="${FOLDER##*@}"
else
URL="${URL##https:\/\/}"
IFS='/'
read -r FOLDER URL <<< "$URL"
fi
URL="${URL//\//-}"
URL="${URL%%.git}"
mkdir -p "$HOME/Code/$FOLDER"
git clone "$1" "$HOME/Code/$FOLDER/$URL"
cd "$HOME/Code/$FOLDER/$URL"
pwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment