Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save schutzsmith/6d3b3ada1d307106efa552489cb68420 to your computer and use it in GitHub Desktop.

Select an option

Save schutzsmith/6d3b3ada1d307106efa552489cb68420 to your computer and use it in GitHub Desktop.
GitHub repository creation alias for zshrc
# GitHub repository creation alias
function create_github_repo() {
echo "Enter repository name:"
read repo_name
gh repo create "$repo_name" --private
# Get the GitHub username from gh cli
github_username=$(gh api user | grep login | cut -d'"' -f4)
git init
# gh auth login
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin "[email protected]:$github_username/$repo_name.git"
git push -u origin main
git status
echo "Repository $repo_name created and initialized successfully!"
}
alias ghcreate='create_github_repo'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment