From be95574e99d681ffa006d783bf8bf1f488bc123e Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Wed, 1 Mar 2023 08:16:35 +1030 Subject: [PATCH] add initial clone script --- .config/shell/profile | 2 ++ .local/bin/clone | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 .local/bin/clone diff --git a/.config/shell/profile b/.config/shell/profile index 6808510..89d5cad 100644 --- a/.config/shell/profile +++ b/.config/shell/profile @@ -59,6 +59,8 @@ export MOZ_USE_XINPUT2="1" # Mozilla smooth scrolling/touchpads. export AWT_TOOLKIT="MToolkit wmname LG3D" #May have to install wmname export _JAVA_AWT_WM_NONREPARENTING=1 # Fix for Java applications in dwm export ZK_NOTEBOOK_DIR="$HOME/notes/zk" +export REPOS="$HOME/repos" +export GITUSER="inkletblot" # This is something luke smith has in his profile (which I have stolen, it's nice but diff --git a/.local/bin/clone b/.local/bin/clone new file mode 100755 index 0000000..9224f42 --- /dev/null +++ b/.local/bin/clone @@ -0,0 +1,24 @@ +#!/bin/bash + +repo="$1" user +repo="${repo#https://github.com +repo="${repo#git@github.com:}" + +if [[ $repo =~ / ]]; then + user="${repo%%/*}" +else + user="$GITUSER" + [[ -z "$user" ]] && user="$USER" +fi + +name="${repo##*/}" +userd="$REPOS/github.com/$user" +path="$userd/$name" + +[[ -d "$path" ]] && cd "$path" && return + +mkdir -p "$userd" +cd "$userd" +echo gh repo clone "$user/$name" -- --recurse-submodule +gh repo clone "$user/$name" -- --recurse-submodule +cd "$name"