| ... | ... |
@@ -4,3 +4,44 @@ if [ "$commands[(I)hub]" ]; then |
| 4 | 4 |
# eval `hub alias -s zsh` |
| 5 | 5 |
function git(){hub "$@"}
|
| 6 | 6 |
fi |
| 7 |
+ |
|
| 8 |
+# Functions ################################################################# |
|
| 9 |
+ |
|
| 10 |
+# https://github.com/dbb |
|
| 11 |
+ |
|
| 12 |
+# These are taken directly from the instructions you see after you create a new |
|
| 13 |
+# repo. As the names imply, new_gh() assumes you're starting from scratch in a |
|
| 14 |
+# directory named after the repo (this name is the only argument it takes), and |
|
| 15 |
+# exist_gh() assumes that you've already initialized git in the given directory |
|
| 16 |
+# (again, the only argument). |
|
| 17 |
+# set up a new repo |
|
| 18 |
+ |
|
| 19 |
+new_gh() { # [NAME_OF_REPO]
|
|
| 20 |
+ repo = $1 |
|
| 21 |
+ |
|
| 22 |
+ name=$( igit config user.name ) |
|
| 23 |
+ email=$( git config user.email ) |
|
| 24 |
+ user=$( git config github.user ) |
|
| 25 |
+ |
|
| 26 |
+ mkdir "$repo" |
|
| 27 |
+ cd "$repo" |
|
| 28 |
+ git init |
|
| 29 |
+ touch README |
|
| 30 |
+ git add README |
|
| 31 |
+ git commit -m 'Initial commit.' |
|
| 32 |
+ git remote add origin git@github.com:${user}/${name}.git
|
|
| 33 |
+ git push -u origin master |
|
| 34 |
+} |
|
| 35 |
+ |
|
| 36 |
+exist_gh() { # [DIRECTORY]
|
|
| 37 |
+ cd "$1" |
|
| 38 |
+ name=$( git config user.name ) |
|
| 39 |
+ email=$( git config user.email ) |
|
| 40 |
+ user=$( git config github.user ) |
|
| 41 |
+ |
|
| 42 |
+ git remote add origin git@github.com:${user}/${name}.git
|
|
| 43 |
+ git push -u origin master |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+# End Functions ############################################################# |
|
| 47 |
+ |