8c48f10a04ce8e6c789cead457e062602cc89931

Author
Daniel Bolton <dbb@9y.com>
Committer
Daniel Bolton <dbb@9y.com>
Date

Message

Add functions for new GH repos.

Diff

 1diff --git a/plugins/github/github.plugin.zsh b/plugins/github/github.plugin.zsh
 2index e5f59097deee36b17156a45f5549b21aa7601c4a..fc51b173c4c9489dddd3a47a860cc51ef287e287 100644
 3--- a/plugins/github/github.plugin.zsh
 4+++ b/plugins/github/github.plugin.zsh
 5@@ -9,19 +9,13 @@ fi
 6 
 7 # https://github.com/dbb 
 8 
 9-# These are taken directly from the instructions you see after you create a new
10-# repo. As the names imply, new_gh() assumes you're starting from scratch in a
11-# directory named after the repo (this name is the only argument it takes), and
12-# exist_gh() assumes that you've already initialized git in the given directory
13-# (again, the only argument).
14-# set up a new repo
15-
16-new_gh() { # [NAME_OF_REPO]
17-    repo = $1
18 
19-    name=$(  igit config user.name )
20-    email=$( git config user.email )
21-    user=$(  git config github.user )
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@@ -29,17 +23,37 @@ new_gh() { # [NAME_OF_REPO]
32     touch README
33     git add README
34     git commit -m 'Initial commit.'
35-    git remote add origin git@github.com:${user}/${name}.git
36+    git remote add origin git@github.com:${ghuser}/${repo}.git
37+    git push -u origin master
38+}
39+
40+# new_gh [DIRECTORY]
41+#
42+# Use this when you have a directory that is not yet set up for git.
43+# This function will add all non-hidden files to git.
44+new_gh() { # [DIRECTORY]
45+    cd "$1"
46+    ghuser=$( git config github.user )
47+
48+    git init
49+    # add all non-dot files
50+    print '.*'"\n"'*~' >> .gitignore
51+    git add ^.*
52+    git commit -m 'Initial commit.'
53+    git remote add origin git@github.com:${ghuser}/${repo}.git
54     git push -u origin master
55 }
56 
57+# exist_gh [DIRECTORY]
58+#
59+# Use this when you have a git repo that's ready to go and you want to add it
60+# to your GitHub.
61 exist_gh() { # [DIRECTORY]
62     cd "$1"
63     name=$( git config user.name )
64-    email=$( git config user.email )
65-    user=$( git config github.user )
66+    ghuser=$( git config github.user )
67 
68-    git remote add origin git@github.com:${user}/${name}.git
69+    git remote add origin git@github.com:${ghuser}/${repo}.git
70     git push -u origin master
71 }
72