From 49c38a40f5cfd6ef76795d3c2fd90c8892e976ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Tue, 8 Dec 2020 22:04:06 +0100 Subject: [PATCH] zsh: Make "gb" more ergonomic --- zsh/zshrc.d/20_aliases.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/zsh/zshrc.d/20_aliases.sh b/zsh/zshrc.d/20_aliases.sh index 5b24ed9..3d8eede 100644 --- a/zsh/zshrc.d/20_aliases.sh +++ b/zsh/zshrc.d/20_aliases.sh @@ -289,10 +289,15 @@ clip() { gb() { _superproject="$(git rev-parse --show-superproject-working-tree)" + _root="$(git rev-parse --show-toplevel)" if [[ -n "${_superproject}" ]] ; then - builtin cd "${_superproject}" + if [[ "$(pwd)" == "${_root}" ]] ; then + builtin cd "${_superproject}" + else + builtin cd "${_root}" + fi else - builtin cd "$(git rev-parse --show-toplevel)" + builtin cd "${_root}" fi }