Created
August 30, 2022 04:24
-
-
Save joshuamorony/9a73a2c033014c754c81d8dc3e49ba54 to your computer and use it in GitHub Desktop.
Alias for creating playground applications and sharing to GitHub/StackBlitz
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
resetAndOpen(){ | |
git switch main --discard-changes | |
git reset --hard | |
git clean -fd | |
code . | |
} | |
createGitRepo(){ | |
read -q "REPLY?Are you sure you want to share this publicly? " | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]]; then | |
local sourcePath=`pwd` | |
rsync -r --exclude=.git --exclude=node_modules . ~/Dev/playground/shared/$1 | |
cd ~/Dev/playground/shared/$1 | |
git init | |
git add . | |
git commit -m 'initial commit' | |
gh repo create $1 --public --push --source=. --remote=upstream | |
read -q "REPLY?Do you also want to create a StackBlitz? " | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]]; then | |
open "https://stackblitz.com/github/YOUR-GITHUB-USERNAME/$1" | |
else | |
gh repo view -w | |
fi | |
echo "Copy created at $(pwd), remaining in original directory" | |
cd $sourcePath | |
fi | |
} | |
share(){ | |
if [ -z "$1" ]; then | |
read "NAME?What would you like to call this repo? " | |
echo | |
createGitRepo "$NAME" | |
else | |
createGitRepo "$1" | |
fi | |
} | |
alias play-angular="cd ~/Dev/testing/angular && resetAndOpen && ng serve" | |
alias play-ionic="cd ~/Dev/testing/ionic && git checkout -- . && code . && ionic serve" | |
alias play-nx="cd ~/Dev/testing/nx && git checkout -- . && code ." |
Hey @joshuamorony ! I just finished watching your YouTube video, and I’m truly impressed!
I really enjoyed the content and created a .bash version inspired by yours, which includes a command to create Angular projects using npx with a specific Angular version.
Thank you for the inspiration!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's a great idea for playing and sharing. It could be a top downloads vscode plugin!!!