github.plugin.zsh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Setup hub function for git, if it is available; http://github.com/defunkt/hub
  2. if [ "$commands[(I)hub]" ] && [ "$commands[(I)ruby]" ]; then
  3. # eval `hub alias -s zsh`
  4. function git(){hub "$@"}
  5. fi
  6. # Functions #################################################################
  7. # https://github.com/dbb
  8. # empty_gh [NAME_OF_REPO]
  9. #
  10. # Use this when creating a new repo from scratch.
  11. empty_gh() { # [NAME_OF_REPO]
  12. repo = $1
  13. ghuser=$( git config github.user )
  14. mkdir "$repo"
  15. cd "$repo"
  16. git init
  17. touch README
  18. git add README
  19. git commit -m 'Initial commit.'
  20. git remote add origin git@github.com:${ghuser}/${repo}.git
  21. git push -u origin master
  22. }
  23. # new_gh [DIRECTORY]
  24. #
  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]
  28. cd "$1"
  29. ghuser=$( git config github.user )
  30. git init
  31. # add all non-dot files
  32. print '.*'"\n"'*~' >> .gitignore
  33. git add ^.*
  34. git commit -m 'Initial commit.'
  35. git remote add origin git@github.com:${ghuser}/${repo}.git
  36. git push -u origin master
  37. }
  38. # exist_gh [DIRECTORY]
  39. #
  40. # Use this when you have a git repo that's ready to go and you want to add it
  41. # to your GitHub.
  42. exist_gh() { # [DIRECTORY]
  43. cd "$1"
  44. name=$( git config user.name )
  45. ghuser=$( git config github.user )
  46. git remote add origin git@github.com:${ghuser}/${repo}.git
  47. git push -u origin master
  48. }
  49. # End Functions #############################################################