A zsh `middleware` forcing user to confirm before executing commands
with preconfigured texts/regex patterns.
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.
Export env var SKIP_CONFIRM=true
if you want to temporarily ignore the middleware.
Requirements:
```bash git clone git@github.com:anhtumai/confirm.git cargo build --release cp target/release/confirm /usr/local/bin
which confirm
```
YAML
- contain: string
description (optional): string
regex (optional): bool
regex
optiontrue
, contain
will be treated as a regex pattern.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 ```
Remove the above lines in .zshrc
and run rm /usr/local/bin/confirm