mirror of
https://github.com/theniceboy/.config.git
synced 2025-12-26 22:54:59 +08:00
cd_git_root
This commit is contained in:
parent
943a9b7c89
commit
c80ad6b584
2 changed files with 12 additions and 0 deletions
10
zsh/functions/cd_git_root.zsh
Normal file
10
zsh/functions/cd_git_root.zsh
Normal 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
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue