# rcaloras/bash-preexec

⚡ preexec and precmd functions for Bash just like Zsh.

Repository: https://github.com/rcaloras/bash-preexec
Canonical: https://ross.abutalabs.com/products/bash-preexec
Language: Shell
License: MIT
License Family: permissive
Topics: bash, preexec, precmd
Last push: 2026-08-24T01:33:23+00:00

## Health v2 (maintenance only)
Score: 88/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 67, longevity 100
- inputs: {"age_days": 4292, "days_push": 10, "days_rel": 10, "gap_med": 385, "n_releases_24m": 2}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1061, forks 104 (observed 2026-08-28T04:03:25.900844+00:00)

## What it is
A single-file shell library that brings Zsh-style preexec and precmd hook functions to Bash 3.1+. It lets scripts and tools run code just before command execution and just before each prompt, with support for hook function arrays.

## Use cases
- run a hook before each bash command executes
- replace PROMPT_COMMAND with something more reliable
- track command execution time in bash
- integrate shell history tools like Atuin with bash
- build custom bash prompt logic
- capture the typed command for logging or syncing

## When to choose
- you need Zsh-style preexec/precmd hooks in Bash
- you're building a shell integration for a terminal or history tool that must support Bash
- PROMPT_COMMAND is too fragile for your prompt or hook needs

## When to avoid
- you're using Zsh, fish, or another shell with native hooks
- you only need simple prompt customization without hooks
- you need hooks in a non-Bash POSIX shell like dash

## Facets
- artifact type: library
- maturity: stable
- function: developer-tools, cli, middleware
- domain: developer-tools, command-line
- platform: cli, cross-platform
- tags: bash, shell-hooks, preexec, precmd, zsh-style, prompt-command, terminal, command-line, linux, macos

## Member repositories
- rcaloras/bash-preexec (main) score 88

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:25.900844+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T06:56:52.092113+00:00, confidence not recorded.
  - readme: https://github.com/rcaloras/bash-preexec (fetched 2026-08-28T04:03:25.900844+00:00, sha a79a7a8c6fde)
- Data as of 2026-08-30T08:39:29.467469+00:00.
