1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-05 09:43:38 +08:00
ohmyzsh/plugins/github/github.plugin.zsh

77 lines
1.7 KiB
Bash
Raw Normal View History

# Set up hub wrapper for git, if it is available; https://github.com/github/hub
if (( $+commands[hub] )); then
alias git=hub
fi
2011-08-07 03:58:40 +08:00
# Functions #################################################################
# Based on https://github.com/dbb/githome/blob/master/.config/zsh/functions
2011-08-07 03:58:40 +08:00
# empty_gh <NAME_OF_REPO>
2011-08-07 04:15:09 +08:00
#
# Use this when creating a new repo from scratch.
# Creates a new repo with a blank README.md in it and pushes it up to GitHub.
2011-08-07 04:15:09 +08:00
empty_gh() { # [NAME_OF_REPO]
emulate -L zsh
local repo=$1
2011-08-07 03:58:40 +08:00
mkdir "$repo"
touch "$repo/README.md"
new_gh "$repo"
2011-08-07 04:15:09 +08: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]
emulate -L zsh
local repo="$1"
cd "$repo" \
|| return
2011-08-07 04:15:09 +08:00
git init \
|| return
# add all non-dot files
print '.*'"\n"'*~' >> .gitignore
git add [^.]* \
|| return
git add -f .gitignore \
|| return
git commit -m 'Initial commit.' \
|| return
hub create \
|| return
git push -u origin master \
|| return
2011-08-07 03:58:40 +08:00
}
2011-08-07 04:15:09 +08: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-07 03:58:40 +08:00
exist_gh() { # [DIRECTORY]
emulate -L zsh
local repo=$1
cd "$repo"
2011-08-07 03:58:40 +08:00
hub create \
|| return
git push -u origin master
2011-08-07 03:58:40 +08:00
}
2014-03-11 06:18:50 +08:00
# git.io "GitHub URL"
#
# Shorten GitHub url, example:
# https://github.com/nvogel/dotzsh > https://git.io/8nU25w
2014-03-11 06:18:50 +08:00
# source: https://github.com/nvogel/dotzsh
# documentation: https://github.com/blog/985-git-io-github-url-shortener
#
git.io() {
emulate -L zsh
curl -i -s https://git.io -F "url=$1" | grep "Location" | cut -f 2 -d " "
}
2014-03-11 06:18:50 +08:00
2011-08-07 03:58:40 +08:00
# End Functions #############################################################