1 # Set up hub wrapper for git, if it is available; https://github.com/github/hub
2 if (( $+commands[hub] )); then
6 # Functions #################################################################
8 # Based on https://github.com/dbb/githome/blob/master/.config/zsh/functions
10 # empty_gh <NAME_OF_REPO>
12 # Use this when creating a new repo from scratch.
13 # Creates a new repo with a blank README.md in it and pushes it up to GitHub.
14 empty_gh() { # [NAME_OF_REPO]
19 touch "$repo/README.md"
25 # Use this when you have a directory that is not yet set up for git.
26 # This function will add all non-hidden files to git.
27 new_gh() { # [DIRECTORY]
35 # add all non-dot files
36 print '.*'"\n"'*~' >> .gitignore
39 git add -f .gitignore \
41 git commit -m 'Initial commit.' \
45 git push -u origin master \
49 # exist_gh [DIRECTORY]
51 # Use this when you have a git repo that's ready to go and you want to add it
53 exist_gh() { # [DIRECTORY]
60 git push -u origin master
65 # Shorten GitHub url, example:
66 # https://github.com/nvogel/dotzsh > https://git.io/8nU25w
67 # source: https://github.com/nvogel/dotzsh
68 # documentation: https://github.com/blog/985-git-io-github-url-shortener
72 # curl -i -s https://git.io -F "url=$1" | grep "Location" | cut -f 2 -d " "
73 print -u2 ${(%):-"%F{yellow}%BThe \`git.io\` is deprecated.%b\nView the announcement made by GitHub: https://github.blog/changelog/2022-01-11-git-io-no-longer-accepts-new-urls/%f"}
76 # End Functions #############################################################