You could change the behavior of cd
cd() {
command cd "$@"
[[ -d ".git" ]] && git pull --autostash
}
I think it's good to use test there so that there won't be an error every time you cd into a directory that isn't a git clone.
I have something similar in place for activating virtualenv every time I enter a directory that has a virtualenv setup with the same name.
Adam Bene
Founder & CTO @ Bene Studio | Join us!
The best you can do is an alias in your shell:
alias cdgp='function _cdgp(){ cd $1; git pull --autostash; };_cdgp'Then do:
cdgp ~/mygitrepo