Add gh_clone_repo function
authorSiraaj Khandkar <siraaj@khandkar.net>
Fri, 19 Apr 2019 19:09:19 +0000 (15:09 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Fri, 19 Apr 2019 19:09:19 +0000 (15:09 -0400)
to cd to archive directory and clone given repo

lib/login_functions.sh

index 29bc3e2..950eb6f 100644 (file)
@@ -91,6 +91,15 @@ gh_clone_org() {
     gh_clone 'orgs' "$1"
 }
 
+gh_clone_repo() {
+    gh_username=$(echo "$1" | awk -F / '"$1 == "https" && $3 == github.com" {print $4}')
+    gh_dir="${HOME}/Archives/Software/src/repos/remote/github.com/${gh_username}"
+    mkdir -p "$gh_dir"
+    cd "$gh_dir" || exit 1
+    git clone "$1"
+    cd - || exit 1
+}
+
 work_log_template() {
 cat << EOF
 $(date +%F)
This page took 0.026796 seconds and 4 git commands to generate.