diff --git a/bin/git-fork b/bin/git-fork index b3e4098..a1d93ca 100755 --- a/bin/git-fork +++ b/bin/git-fork @@ -5,8 +5,12 @@ abort() { exit 1 } +url="$1" + +test -z "$url" && url=`git remote get-url origin 2> /dev/null` + # validate repo url -test -z "$1" && abort "github repo needs to be specified as an argument" +test -z "$url" && abort "github repo needs to be specified as an argument" # validate user echo "Enter your github username" @@ -14,8 +18,8 @@ read user [ "$user" = 'n' ] && abort "git username required" # extract owner + project from repo url -project=${1##*/} -owner=${1%/$project} +project=${url##*/} +owner=${url%/$project} [[ $project == *.git ]] && project=${project%.git} if [[ $owner == git@* ]]; then owner=${owner##*:}