2018-08-07 18:42:02 +00:00
|
|
|
# Set up hub wrapper for git, if it is available; https://github.com/github/hub
|
2018-04-24 20:02:58 +00:00
|
|
|
if (( $+commands[hub] )); then
|
|
|
|
alias git=hub
|
2011-03-04 02:38:56 +00:00
|
|
|
fi
|
2011-08-06 19:58:40 +00:00
|
|
|
|
|
|
|
# Functions #################################################################
|
|
|
|
|
2015-10-02 05:21:29 +00:00
|
|
|
# Based on https://github.com/dbb/githome/blob/master/.config/zsh/functions
|
2011-08-06 19:58:40 +00:00
|
|
|
|
2015-10-02 05:21:29 +00:00
|
|
|
# empty_gh <NAME_OF_REPO>
|
2011-08-06 20:15:09 +00:00
|
|
|
#
|
|
|
|
# Use this when creating a new repo from scratch.
|
2015-10-02 05:21:29 +00:00
|
|
|
# Creates a new repo with a blank README.md in it and pushes it up to GitHub.
|
2011-08-06 20:15:09 +00:00
|
|
|
empty_gh() { # [NAME_OF_REPO]
|
2015-10-02 05:21:29 +00:00
|
|
|
emulate -L zsh
|
|
|
|
local repo=$1
|
2011-08-06 19:58:40 +00:00
|
|
|
|
2015-10-02 05:21:29 +00:00
|
|
|
mkdir "$repo"
|
|
|
|
touch "$repo/README.md"
|
|
|
|
new_gh "$repo"
|
2011-08-06 20:15:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# new_gh [DIRECTORY]
|
|
|
|
#
|
|
|
|
# Use this when you have a directory that is not yet set up for git.
|
|
|
|
# This function will add all non-hidden files to git.
|
|
|
|
new_gh() { # [DIRECTORY]
|
2015-10-02 05:21:29 +00:00
|
|
|
emulate -L zsh
|
|
|
|
local repo="$1"
|
|
|
|
cd "$repo" \
|
|
|
|
|| return
|
2011-08-06 20:15:09 +00:00
|
|
|
|
2015-10-02 05:21:29 +00:00
|
|
|
git init \
|
|
|
|
|| return
|
|
|
|
# add all non-dot files
|
|
|
|
print '.*'"\n"'*~' >> .gitignore
|
|
|
|
git add [^.]* \
|
|
|
|
|| return
|
2018-08-23 18:01:01 +00:00
|
|
|
git add -f .gitignore \
|
2015-10-02 05:21:29 +00:00
|
|
|
|| return
|
|
|
|
git commit -m 'Initial commit.' \
|
|
|
|
|| return
|
|
|
|
hub create \
|
|
|
|
|| return
|
|
|
|
git push -u origin master \
|
|
|
|
|| return
|
2011-08-06 19:58:40 +00:00
|
|
|
}
|
|
|
|
|
2011-08-06 20:15:09 +00:00
|
|
|
# exist_gh [DIRECTORY]
|
|
|
|
#
|
|
|
|
# Use this when you have a git repo that's ready to go and you want to add it
|
|
|
|
# to your GitHub.
|
2011-08-06 19:58:40 +00:00
|
|
|
exist_gh() { # [DIRECTORY]
|
2015-10-02 05:21:29 +00:00
|
|
|
emulate -L zsh
|
|
|
|
local repo=$1
|
|
|
|
cd "$repo"
|
2011-08-06 19:58:40 +00:00
|
|
|
|
2015-10-02 05:21:29 +00:00
|
|
|
hub create \
|
|
|
|
|| return
|
|
|
|
git push -u origin master
|
2011-08-06 19:58:40 +00:00
|
|
|
}
|
|
|
|
|
2014-03-10 22:18:50 +00:00
|
|
|
# git.io "GitHub URL"
|
|
|
|
#
|
|
|
|
# Shorten GitHub url, example:
|
2018-08-07 18:42:02 +00:00
|
|
|
# https://github.com/nvogel/dotzsh > https://git.io/8nU25w
|
2014-03-10 22:18:50 +00:00
|
|
|
# source: https://github.com/nvogel/dotzsh
|
|
|
|
# documentation: https://github.com/blog/985-git-io-github-url-shortener
|
|
|
|
#
|
2015-10-02 05:21:29 +00:00
|
|
|
git.io() {
|
|
|
|
emulate -L zsh
|
2016-04-16 01:22:58 +00:00
|
|
|
curl -i -s https://git.io -F "url=$1" | grep "Location" | cut -f 2 -d " "
|
2015-10-02 05:21:29 +00:00
|
|
|
}
|
2014-03-10 22:18:50 +00:00
|
|
|
|
2011-08-06 19:58:40 +00:00
|
|
|
# End Functions #############################################################
|
|
|
|
|