Automatic git pull on directory change for Nushell.
Automatically pulls git repositories when you cd into them - but only if it's safe:
- ✅ Working directory is clean (no uncommitted changes)
- ✅ Fast-forward is possible (no merge conflicts)
- ✅ Repository has an upstream branch
- ✅ Only works in
~/sourcedirectory - ✅ Smart cooldown (5 min) prevents spam
Copy git-auto-pull.nu to your Nushell autoload directory:
Linux / macOS:
cp git-auto-pull.nu ~/.config/nushell/autoload/Windows:
cp git-auto-pull.nu ~/AppData/Roaming/nushell/autoload/Create autoload directory if it doesn't exist:
mkdir ($nu.user-autoload-dirs | first)Then restart Nushell.
By default, auto-pull only works in ~/source. To change this, edit line 13 in git-auto-pull.nu:
let BASE_REPOS_DIR = ($home | path join "your-directory-name")To change the cooldown period, edit line 61:
if ($age < 10min) { return } # Change 5min to whatever you wantJust navigate to any git repository:
cd ~/source/my-project
# 🔄 Checking for updates...
# ✅ OKClean repo with updates:
🔄 Checking for updates...
✅ OK
Uncommitted changes:
⚠️ Uncommitted changes - skipping
Cannot fast-forward:
⚠️ Cannot fast-forward
No upstream / outside ~/source:
(no output)
- Registers a Nushell hook on directory (
PWD) changes - Checks if new directory is a git repository
- Verifies repository is in
~/source - Checks cooldown cache (5 min)
- Ensures working directory is clean
- Fetches and pulls with
--ff-only
- Nushell >= 0.80.0
- Git
Module not loading?
Check your autoload directory:
$nu.user-autoload-dirs | firstCreate it if missing:
mkdir ($nu.user-autoload-dirs | first)Not working in my repos?
Make sure your repositories are in ~/source or edit the BASE_REPOS_DIR variable.
MIT License
Made by Marlena Makosza