Last active
January 9, 2018 10:09
-
-
Save CMarzin/0c8fdebdcde21776336b6b897454a2d8 to your computer and use it in GitHub Desktop.
Clone your own repo to anywhere you want in 2 command
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
#!/bin/bash | |
URL=$(curl -s 'https://api.github.com/user/repos?sort=pushedaccess_token=YOUR_PERSONNAL_GITHUB_TOKEN' | jq '.[] | .ssh_url' ); | |
URL=${URL[@]//\"/}; | |
clone(){ | |
echo "Git clone: '$@'" | |
git clone $@ | |
REPO=$@ | |
temp=$(echo "$REPO" | grep -Po '(?<=\/)(.*?)(?=\.)') | |
echo "Now you can do :" | |
echo cd $temp | |
} | |
title="Select a git repositories" | |
prompt="Choose a repositorie:" | |
options=($URL) | |
echo "$title" | |
PS3="$prompt " | |
select opt in "${options[@]}" "Quit"; do | |
case "$REPLY" in | |
$(( ${#options[@]}+1 )) ) echo "Goodbye!"; break;; | |
$REPLY ) echo "You choose $opt"; | |
clone "$opt"; | |
break;; | |
*) echo "Invalid option. Try another one.";continue;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For functionning you need to install jq first :
Little explanation
Make the script executable :
Add permission :
Launch the script in the directory you choose
Personally I move this tiny script in my root directory
I recommend you to create an alias in your .bashr or .zshrc
Enjoy !