From 714399a7c33963384ef7f21ce21f6d134416f9aa Mon Sep 17 00:00:00 2001 From: fanuch Date: Sun, 6 Oct 2019 13:19:14 +1100 Subject: [PATCH] feat(git): add `gccd` alias to clone and cd into git repository (#8220) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #8216 Closes #8220 Co-authored-by: Nelson Estevão --- plugins/git/README.md | 1 + plugins/git/git.plugin.zsh | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/plugins/git/README.md b/plugins/git/README.md index 05ef25099..b68dc552e 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -47,6 +47,7 @@ plugins=(... git) | gcb | git checkout -b | | gcf | git config --list | | gcl | git clone --recurse-submodules | +| gccd | git clone --recurse-submodules "$@" && cd "$(basename $_ .git)" | | gclean | git clean -id | | gpristine | git reset --hard && git clean -dffx | | gcm | git checkout $(git_main_branch) | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 11dff99d9..f2431fde5 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -97,6 +97,13 @@ alias gcas='git commit -a -s' alias gcasm='git commit -a -s -m' alias gcb='git checkout -b' alias gcf='git config --list' + +function gccd() { + command git clone --recurse-submodules "$@" + [[ -d "$_" ]] && cd "$_" || cd "${${_:h}%.git}" +} +compdef _git gccd=git-clone + alias gcl='git clone --recurse-submodules' alias gclean='git clean -id' alias gpristine='git reset --hard && git clean -dffx'