Created
October 25, 2023 13:57
-
-
Save wilsonsilva/be7f3c368a7c34dc454c4db39f3ae98f to your computer and use it in GitHub Desktop.
Clone github repo in the github folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
gh
dependency could be removed by usinggit
directlyThe
wd
dependency could be removed by hardcoding the github directory path