]> git.rmz.io Git - dotfiles.git/blob - zsh/plugins/github/github.plugin.zsh
598b059c18753f0f76002a2e93046f037c1c9e56
[dotfiles.git] / zsh / plugins / github / github.plugin.zsh
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
17 # Functions #################################################################
18
19 # https://github.com/dbb
20
21
22 # empty_gh [NAME_OF_REPO]
23 #
24 # Use this when creating a new repo from scratch.
25 empty_gh() { # [NAME_OF_REPO]
26 repo = $1
27 ghuser=$( git config github.user )
28
29 mkdir "$repo"
30 cd "$repo"
31 git init
32 touch README
33 git add README
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
39 # new_gh [DIRECTORY]
40 #
41 # Use this when you have a directory that is not yet set up for git.
42 # This function will add all non-hidden files to git.
43 new_gh() { # [DIRECTORY]
44 cd "$1"
45 ghuser=$( git config github.user )
46
47 git init
48 # add all non-dot files
49 print '.*'"\n"'*~' >> .gitignore
50 git add ^.*
51 git commit -m 'Initial commit.'
52 git remote add origin git@github.com:${ghuser}/${repo}.git
53 git push -u origin master
54 }
55
56 # exist_gh [DIRECTORY]
57 #
58 # Use this when you have a git repo that's ready to go and you want to add it
59 # to your GitHub.
60 exist_gh() { # [DIRECTORY]
61 cd "$1"
62 name=$( git config user.name )
63 ghuser=$( git config github.user )
64 repo=$1
65
66 git remote add origin git@github.com:${ghuser}/${repo}.git
67 git push -u origin master
68 }
69
70 # End Functions #############################################################
71