Last active
May 5, 2019 18:16
-
-
Save tamakiii/c61b0e683767c1fbe343504a8724c46c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - https://github.com/github/hub | |
# - https://github.com/junegunn/fzf | |
# - https://stedolan.github.io/jq/ | |
# - http://linuxcommand.org/lc3_adv_tput.php | |
# - https://unix.stackexchange.com/questions/26576/how-to-delete-line-with-echo | |
# - https://www.ibm.com/developerworks/jp/aix/library/au-learningtput/index.html | |
(ROOT_DIR=~/Sites && echo -n "Organization: " && ORGANIZATION=$(if type hub 2>&1 > /dev/null; then hub api /user/orgs | jq -r '.[].login' | fzf --no-sort --layout=reverse --height=20; else read X && echo $X; fi); [[ -z "$ORGANIZATION" ]] && echo "Please specify organization" && exit 1 || echo -ne "$(tput el)" && echo -n "Repository: " && read REPOSITORY && echo -n "$(tput cuu1)$(tput el 2)" && echo -n "Create $(tput setaf 2)\"${ORGANIZATION}/${REPOSITORY}\"$(tput sgr0)? (y/N): " && read yn; [[ $yn != [yY] ]] && exit 3 || [[ -d "${ROOT_DIR}/${ORGANIZATION}/${REPOSITORY}" ]] && echo "Directory already exists" && exit 2 || mkdir ${ROOT_DIR}/${ORGANIZATION}/${REPOSITORY} && cd $_ && git init && echo "# ${REPOSITORY}" > README.md && git add README.md && git commit -m 'init' && (if type hub 2>&1 > /dev/null; then hub create "${ORGANIZATION}/${REPOSITORY}"; else open "https://github.com/organizations/${ORGANIZATION}/repositories/new?name=${REPOSITORY}"; fi) && [[ -z "$(git remote get-url origin 2> /dev/null)" ]] && git remote add origin [email protected]:${ORGANIZATION}/${REPOSITORY}.git || git push && open "https://github.com/${ORGANIZATION}/${REPOSITORY}" && echo "${ROOT_DIR}/${ORGANIZATION}/${REPOSITORY}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment