diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 9006479..6521f5d 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -65,12 +65,17 @@ if command -v tig &>/dev/null; then alias tiga='tig --all' fi -# Function to run after every 'cd' command chpwd() { - # Check if the current directory is a Git repository - if git rev-parse --is-inside-work-tree 2>/dev/null; then - echo "Fetching latest changes from remote..." - git fetch + # Is this directory inside a git repo? + if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + + # Are we at the repo root? (prefix empty = root) + + if [ -z "$(git rev-parse --show-prefix)" ]; then + echo "Fetching latest changes from remote..." + git fetch --quiet + fi + fi } @@ -148,7 +153,7 @@ export ZSH_TMUX_DEFAULT_SESSION_NAME=build if command -v fzf &>/dev/null; then change_path_and_find_project() { - z {{ .projectdir }} + cd {{ .projectdir }} zle fzf-cd-widget zle reset-prompt } @@ -217,3 +222,4 @@ if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then nix-env -qa --description ".*$1.*" } fi +