aboutsummaryrefslogtreecommitdiff
path: root/templates/.zsh/functions/ghclone.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'templates/.zsh/functions/ghclone.zsh')
-rw-r--r--templates/.zsh/functions/ghclone.zsh19
1 files changed, 19 insertions, 0 deletions
diff --git a/templates/.zsh/functions/ghclone.zsh b/templates/.zsh/functions/ghclone.zsh
new file mode 100644
index 0000000..7b976ef
--- /dev/null
+++ b/templates/.zsh/functions/ghclone.zsh
@@ -0,0 +1,19 @@
+function ghclone() {
+ local username
+ local repo
+ local target_dir
+
+ if [[ $# -lt 1 ]]; then
+ echo "Usage: ghclone <username/repo>"
+ return 1
+ fi
+
+ username=$(echo "$1" | cut -d'/' -f1)
+ repo=$(echo "$1" | cut -d'/' -f2)
+ target_dir="$PROJECTS/src/github.com/$username"
+ mkdir -p "$target_dir"
+ url="git@github.com:$username/$repo.git"
+ echo "Cloning $url into $target_dir..."
+ git clone "$url" "$target_dir/$repo"
+ cd "$target_dir/$repo" || return
+}