From 532a23788c0c79b8a18a6d2e0085b8c7fc784d9d Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Fri, 11 Oct 2024 21:51:19 +0300 Subject: [PATCH] Git : Add gcd. --- home/program/bash/module/Git.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/home/program/bash/module/Git.nix b/home/program/bash/module/Git.nix index 4b02a38..53c8783 100644 --- a/home/program/bash/module/Git.nix +++ b/home/program/bash/module/Git.nix @@ -39,6 +39,13 @@ git stash "''${@}" } + # Cd to git's root dir. + function gcd() { + local path=$(git rev-parse --show-toplevel) + [[ "''${path}" = "" ]] && return 1 + cd "''${path}" + } + # Git diff. function gd() { git diff "''${@}"