Skip to content

Instantly share code, notes, and snippets.

@wilsonsilva
Created October 25, 2023 13:57
Show Gist options
  • Save wilsonsilva/be7f3c368a7c34dc454c4db39f3ae98f to your computer and use it in GitHub Desktop.
Save wilsonsilva/be7f3c368a7c34dc454c4db39f3ae98f to your computer and use it in GitHub Desktop.
Clone github repo in the github folder
# Creates a directory called username in the github folder, clones the repo and cd's into the repo
# Add it to .zshrc
# requires gh, wd and a warp point called 'github'
# wd: https://github.com/mfaerevaag/wd
# gh: https://cli.github.com
# Usage: gclone username/repo
gclone() {
if [ -z "$1" ]; then
echo "Usage: gclone <username/repo>"
else
wd github
folder_name=$(echo "$1" | cut -d "/" -f1)
repo_name=$(echo "$1" | cut -d "/" -f2)
mkdir -p "$folder_name"
cd "$folder_name"
gh repo clone "$1"
cd "$repo_name"
fi
}
@wilsonsilva
Copy link
Author

wilsonsilva commented Oct 25, 2023

The gh dependency could be removed by using git directly
The wd dependency could be removed by hardcoding the github directory path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment