diff options
Diffstat (limited to 'templates/.zsh/functions/ghclone.zsh')
-rw-r--r-- | templates/.zsh/functions/ghclone.zsh | 19 |
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 +} |