One nice solution to this problem is to use pipx. pipx essentially provides a middle ground between installing nothing to the global python installation and installing everything to the global python installation. pipx is installed into the global python installation and then you use pipx to (1) install (and manage) python-based command line tools (such as pre-commit) within isolated virtual environments and (2) expose those command line tools to the global terminal command namespace. The workflow in this case is:
python -m pip install --user pipxto installpipxto the global python.pipx ensurepathto make sure path is setup correctly.pipx install pre-commitpre-commit installin the git repo of interest- set up
.pre-commit-config.yamlin the git repo of interest - Now
gitcommands should work usingpre-commit(which uses thepre-commitinstalled bypipx) on the repo of interest, whether or not the virtual environment is activated.
Videos
» pip install pre-commit
I'm looking to install some pre-commit hooks locally for existing and future repo's I use. Specifically, I just want to scan files for some text and if it's found not let me commit anything (e.g. password=(.+)).
I went through a few different install steps, but nothing seems to work. Updating my gitconfig to link to a common hooks directory, etc.
How the heck do I do this?
As an aside - anyone able to recommend some "idiot proof" hooks?