Last active
May 31, 2017 20:11
-
-
Save mcansh/6590f9dbbfb5c345b23ba2c5540f4211 to your computer and use it in GitHub Desktop.
clone repo, cd into it, fork it on github, and open it in atom
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
# add this to your `~/.bashrc` or `.zshrc` file | |
# clone repo, cd into it, fork it on github (if its a github repo), and open it in atom | |
# requires https://hub.github.com for forking and cloning (user/repos) | |
alias cloneOpen='f() { | |
urls=('github.com' 'bitbucket.org' 'gitlab.com') | |
url=$1 | |
for i in "${urls[@]}" | |
do | |
if [[ $url =~ $i ]] | |
then | |
if [[ $url =~ 'http://' || $url =~ 'https://' ]] | |
then | |
userRepo=${url#*://$i/} | |
elif [[ $url =~ 'git@' ]] | |
then | |
userRepo=${url#*@$i:} | |
fi | |
repo=${userRepo#*/} | |
repo_no_ext=$(basename ${repo#*/} .git) | |
echo $userRepo | |
echo $repo | |
echo $repo_no_ext | |
if [[ $url =~ 'github.com' ]] | |
then | |
git clone $url && cd $repo_no_ext && git fork && atom . | |
else | |
git clone $url && cd $repo_no_ext && atom . | |
fi | |
fi | |
done | |
};f' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment