Skip to content

Instantly share code, notes, and snippets.

@jhadev
Last active October 12, 2022 11:06
Show Gist options
  • Save jhadev/03f59fdcc9424d03bf0be0ed8f25b224 to your computer and use it in GitHub Desktop.
Save jhadev/03f59fdcc9424d03bf0be0ed8f25b224 to your computer and use it in GitHub Desktop.
create_html_repo.zsh
source ${ZDOTDIR-$HOME}/.zsh/create_html_repo.zsh
export GH_TOKEN=<TOKEN>
export REPO_NAME="$USER-automated-repo"
# create_html_repo my-cool-project
create_html_repo() {
cd ~/Desktop && mkdir $1 && cd $1 && touch index.html && mkdir assets && mkdir assets/js && mkdir assets/css && touch assets/js/script.js && touch assets/css/style.css && echo '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./assets/css/style.css">
</head>
<body>
<h1>Hi!</h1>
<script src="./assets/js/script.js"></script>
</body>
</html>' > index.html
# ls -la
echo default $1
# vared -c -p 'Please enter a repo name: ' REPO_NAME
# echo new $REPO_NAME
REPO_NAME=$1
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
https://api.github.com/user/repos \
-d'{"name":"'"$REPO_NAME"'"}'
set $REPO_NAME=""
echo DONE!
}
@jhadev
Copy link
Author

jhadev commented Oct 12, 2022

move this file to ~/.zsh

source ${ZDOTDIR-$HOME}/.zsh/create_repo.zsh in .zshrc

Create a Personal Access Token in https://github.com/settings/tokens

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