cd_git_root

This commit is contained in:
David Chen 2023-08-12 15:49:33 +08:00
parent 943a9b7c89
commit c80ad6b584
2 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,10 @@
function gr() {
local git_root
git_root=$(git rev-parse --show-toplevel 2>/dev/null)
if [[ $? -eq 0 && -d $git_root ]]; then
cd "$git_root"
else
echo "Not in a git repository or could not find the git root."
fi
}

View file

@ -13,3 +13,5 @@ autopair-init
source ~/.zim/modules/fzf-tab/fzf-tab.plugin.zsh
source ~/.config/zsh/prompt.zsh
source ~/.config/zsh/functions/cd_git_root.zsh