ENV variables

ENV variables control some lefthook behavior. Most of them have the alternative CLI or config options.

LEFTHOOK

Use LEFTHOOK=0 git ... or LEFTHOOK=false git ... to disable lefthook when running git commands.

Example

LEFTHOOK=0 git commit -am "Lefthook skipped"

When using NPM package lefthook in CI, and your CI sets CI=true automatically, use LEFTHOOK=1 or LEFTHOOK=true to install hooks in the postinstall script:

Example

LEFTHOOK=1 npm install
LEFTHOOK=1 yarn install
LEFTHOOK=1 pnpm install

LEFTHOOK_OUTPUT

Use LEFTHOOK_OUTPUT={list of output values} to specify what to print in your output. You can also set LEFTHOOK_OUTPUT=false to disable all output except for errors. Refer to the output configuration option for more details.

Example

$ LEFTHOOK_OUTPUT=summary lefthook run pre-commit
summary: (done in 0.52 seconds)
✔️  lint

LEFTHOOK_VERBOSE

Set LEFTHOOK_VERBOSE=1 or LEFTHOOK_VERBOSE=true to enable verbose printing.

LEFTHOOK_CONFIG

Override the main lefthook config with LEFTHOOK_CONFIG=~/global_lefthook.yml. Note: local config, specified extends, and remotes will still be loaded.

LEFTHOOK_EXCLUDE

Use LEFTHOOK_EXCLUDE={list of tags or command names to be excluded} to skip some commands or scripts by tag or name (for commands only). See the exclude_tags configuration option for more details.

Example

LEFTHOOK_EXCLUDE=ruby,security,lint git commit -am "Skip some tag checks"

NO_COLOR

Set NO_COLOR=true to disable colored output in lefthook and all subcommands that lefthook calls.

CLICOLOR_FORCE

Set CLICOLOR_FORCE=true to force colored output in lefthook and all subcommands.

CI

When using NPM package lefthook, set CI=true in your CI (if it does not set it automatically) to prevent lefthook from installing hooks in the postinstall script:

CI=true npm install
CI=true yarn install
CI=true pnpm install

Note: Set LEFTHOOK=1 or LEFTHOOK=true to override this behavior and install hooks in the postinstall script (despite CI=true).