Preexec Confirm

A zsh `middleware` forcing user to confirm before executing commands with preconfigured texts/regex patterns.

Demo

Users can define a YAML config file, specifying keywords or regex patterns of dangerous commands that they don't want to execute by accident. For example, serverless deploy --stage prod-environment

When the middleware detects a dangerous command, it will force the user to confirm by re-typing a random string, to avoid muscle memory.

Demo

Export env var SKIP_CONFIRM=true if you want to temporarily ignore the middleware.

Skip-confirm-demo

Installation and Usage

Requirements:

1. Build from source

```bash cargo install preexec_confirm

ensure the system recognizes preexec_confirm path

which preexec_confirm

~/.cargo/bin/preexec_confirm

```

2. Create a YAML config file with the following format

YAML - contain: string description (optional): string regex (optional): bool

3. Ensure these lines exist in your .zshrc with correct order

```zshrc function preexecconfirmhook() { CONFIGPATH="/home/anhtumai/.config/confirm/config.yml" #change this preexecconfirm $CONFIG_PATH $1 }

autoload -Uz add-zsh-hook

add-zsh-hook preexec preexecconfirmhook ```

Uninstallation