github.plugin.zsh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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(){
  5. if ! (( $+_has_working_hub )); then
  6. hub --version &> /dev/null
  7. _has_working_hub=$(($? == 0))
  8. fi
  9. if (( $_has_working_hub )) ; then
  10. hub "$@"
  11. else
  12. command git "$@"
  13. fi
  14. }
  15. fi
  16. # Functions #################################################################
  17. # https://github.com/dbb
  18. # empty_gh [NAME_OF_REPO]
  19. #
  20. # Use this when creating a new repo from scratch.
  21. empty_gh() { # [NAME_OF_REPO]
  22. repo = $1
  23. ghuser=$( git config github.user )
  24. mkdir "$repo"
  25. cd "$repo"
  26. git init
  27. touch README
  28. git add README
  29. git commit -m 'Initial commit.'
  30. git remote add origin git@github.com:${ghuser}/${repo}.git
  31. git push -u origin master
  32. }
  33. # new_gh [DIRECTORY]
  34. #
  35. # Use this when you have a directory that is not yet set up for git.
  36. # This function will add all non-hidden files to git.
  37. new_gh() { # [DIRECTORY]
  38. cd "$1"
  39. ghuser=$( git config github.user )
  40. git init
  41. # add all non-dot files
  42. print '.*'"\n"'*~' >> .gitignore
  43. git add ^.*
  44. git commit -m 'Initial commit.'
  45. git remote add origin git@github.com:${ghuser}/${repo}.git
  46. git push -u origin master
  47. }
  48. # exist_gh [DIRECTORY]
  49. #
  50. # Use this when you have a git repo that's ready to go and you want to add it
  51. # to your GitHub.
  52. exist_gh() { # [DIRECTORY]
  53. cd "$1"
  54. name=$( git config user.name )
  55. ghuser=$( git config github.user )
  56. git remote add origin git@github.com:${ghuser}/${repo}.git
  57. git push -u origin master
  58. }
  59. # End Functions #############################################################