Skip to content

MarlenaMakosza/Nushell-git-auto-pull

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🔄 Nushell Auto Git Pull

Automatic git pull on directory change for Nushell.

✨ What it does

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 ~/source directory
  • ✅ Smart cooldown (5 min) prevents spam

📦 Installation

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.

⚙️ Configuration

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 want

🎯 Usage

Just navigate to any git repository:

cd ~/source/my-project
# 🔄 Checking for updates...
# ✅ OK

Example outputs

Clean repo with updates:

🔄 Checking for updates...
✅ OK

Uncommitted changes:

⚠️  Uncommitted changes - skipping

Cannot fast-forward:

⚠️  Cannot fast-forward

No upstream / outside ~/source:

(no output)

🔧 How it works

  1. Registers a Nushell hook on directory (PWD) changes
  2. Checks if new directory is a git repository
  3. Verifies repository is in ~/source
  4. Checks cooldown cache (5 min)
  5. Ensures working directory is clean
  6. Fetches and pulls with --ff-only

📋 Requirements

🐛 Troubleshooting

Module not loading?

Check your autoload directory:

$nu.user-autoload-dirs | first

Create 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.

📄 License

MIT License

👩‍💻 Author

Made by Marlena Makosza

About

Nushell module that automatically pulls git repositories when entering them

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors