Improve git fetch
This commit is contained in:
parent
e046927d0d
commit
b3866294bc
1 changed files with 12 additions and 6 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue