From 0b9d87439096747ab254f485032d6965881d728c Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:58:40 +0200 Subject: [PATCH] Git fetch after each cd --- dot_zshrc.tmpl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 757de3d..cf9fd31 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -64,6 +64,15 @@ 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 + fi +} + # --------------------------------------------------------------------------- # Editor # ---------------------------------------------------------------------------