Improve git fetch

This commit is contained in:
Yax 2026-01-21 07:54:52 +01:00
parent e046927d0d
commit b3866294bc

View file

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