Last active
May 16, 2020 00:29
-
-
Save danielbayley/ac573a4dbf4e30e60a87bb2a3f2dcf9c to your computer and use it in GitHub Desktop.
A useful shim for @git.
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
| #! /bin/zsh --no-rcs --err-exit | |
| # Git/Hub | |
| # TODO $DOTFILES/git/clone.zsh #danielbayley/binstubs #/git | |
| # https://github.com/xreader/git-for-humans | |
| alias clone='git clone' | |
| alias github=hub | |
| #alias git-date='git commit date' | |
| #alias release='git release' #npm TODO | |
| #alias hub=git | |
| if (($+commands[hub])) git () { #alias git=hub | |
| set -- ${${@/*-h*/--help}/*-v*/--version} | |
| case $@ in | |
| init*) command git init && command git commit --allow-empty --message "Initial commit";; | |
| #init*--template*) ?;; #--template= #--separate-git-dir=? | |
| clone*) command git $@ && cd $_:t:r | |
| #hub clone ${@:2} && pushd ${_//(http*\/|.git)/} #$_:t:r #--template=TODO | |
| # Configure [any] git config/hooks. | |
| command git ls-tree -r master --name-only | grep 'git.*config|hooks'| read | |
| case $REPLY in | |
| *git*config*) command git config include.path ../$REPLY;; | |
| *hooks) command git config core.hooksPath $REPLY #$PWD:t | |
| esac | |
| #if pushd *hooks/ | |
| #then command git config core.hooksPath $PWD:t | |
| # Run post-checkout hook after clone. | |
| #[ -x post-checkout ] && ./post-checkout | |
| #popd | |
| #fi | |
| #argv=*gitconfig(D) # Include [any] git config. | |
| #[ -f $1 ] && command git config include.path ../$1;; | |
| rm .git/index | |
| hub checkout --force #git checkout HEAD -- ** | |
| # Automatically install [any] npm dependencies. | |
| [ -f package.* ] && npm install;; #.@(y*ml|?son) | |
| #[ -f Gemfile* ] && gem install TODO | |
| #[ -f Brewfile* ] && brew install --file=Brewfile* | |
| #fork*) #contrib #dev TODO setup remote/origin etc automatically. https://hub.github.com | |
| #hub fork ?;; | |
| commit*--date*) # Also modify AUTHOR date. TODO | |
| zparseopts -- -date:=date | |
| local GIT_COMMITTER_DATE="${date[2]/=/}" #unset GIT_COMMITTER_DATE | |
| # TODO Natural language using npm/chrono | |
| command git $@ --date="'$GIT_COMMITTER_DATE'";; #git-date | |
| *) hub $@ #command git $@ | |
| esac | |
| } | |
| [ $ZSH_EVAL_CONTEXT = toplevel ] && $0:t:r $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment