No description
Find a file
2026-01-11 14:32:42 +01:00
docs docs: expand documentation to cover configuration and custom toml rules 2026-01-11 14:27:20 +01:00
pkg tests: improve test mode detection 2026-01-11 14:32:42 +01:00
shell_configs feat: config system, cleanups 2026-01-06 15:53:43 +01:00
.envrc feat: Port a bunch of more rules 2025-12-30 17:15:18 +01:00
.gitignore feat: Port a bunch of more rules 2025-12-30 17:15:18 +01:00
.golangci.yml feat: Port a more rules from thefuck 2025-12-31 17:47:41 +01:00
.pre-commit-config.yaml feat: bash and zsh integrations 2025-12-30 11:40:11 +01:00
CONTEXT.md feat: Port more simple rules to the toml engine 2026-01-10 15:47:11 +01:00
default.nix feat: port all git related rules 2025-12-29 18:09:08 +01:00
flake.lock chore: setup a nix flake 2025-12-29 16:12:03 +01:00
flake.nix chore: setup a nix flake 2025-12-29 16:12:03 +01:00
go.mod refactor: Levenshtein method is not in use 2026-01-08 00:51:33 +01:00
go.sum feat: config system, cleanups 2026-01-06 15:53:43 +01:00
gomod2nix.toml feat: config system, cleanups 2026-01-06 15:53:43 +01:00
main.go refactor: update most rules to use helpers 2026-01-07 23:20:01 +01:00
Makefile tests: improve test mode detection 2026-01-11 14:32:42 +01:00
priority_test.go feat: Port more simple rules to the toml engine 2026-01-10 15:47:11 +01:00
README.md docs: expand documentation to cover configuration and custom toml rules 2026-01-11 14:27:20 +01:00
shell.nix chore: update dev shell 2025-12-30 11:42:53 +01:00
TODO.md feat: port more rules to toml engine 2026-01-10 16:33:39 +01:00

TheHeck

TheHeck is a Go port of TheFuck, which corrects your previous console command.

Features

  • 168+ correction rules - All rules from TheFuck have been ported
  • Shell integration - Just type heck after any failed command
  • Supports Bash, Zsh, and Fish - Shell-specific integrations
  • Configuration file support - TOML-based configuration (~/.config/theheck/settings.toml)
    • Run theheck init to generate a sample config file
  • Interactive TUI - Beautiful terminal UI for selecting corrections
  • Auto-confirmation mode - Use --yes to skip confirmation

Installation

go install code.bas.es/marcus/theheck@latest

Or build from source:

git clone https://code.bas.es/marcus/theheck
cd theheck
go build

Quick Start

  1. Initialize your configuration:
theheck init
  1. Set up shell integration:

For Bash - Add to ~/.bashrc:

eval "$(theheck alias --shell bash)"
# Or simply: eval "$(theheck bash)"

For Zsh - Add to ~/.zshrc:

eval "$(theheck alias --shell zsh)"
# Or simply: eval "$(theheck zsh)"

For Fish - Add to ~/.config/fish/config.fish:

theheck alias --shell fish | source
# Or simply: theheck fish | source
  1. Restart your shell or source your config:
source ~/.bashrc  # or ~/.zshrc
  1. Now just type heck after any failed command:
$ git puls
# git: 'puls' is not a git command...

$ heck
# Suggests and runs: git pull

The corrected command will be automatically executed and added to your history!

Project Structure

  • main.go: Main entry point
  • pkg/config: Configuration management
  • pkg/types: Core data structures (Command, Rule)
  • pkg/rules: Collection of correction rules (168+ rules)
  • pkg/shell: Shell interaction helpers
  • pkg/tui: Terminal UI components
  • pkg/utils: General utility functions (fuzzy matching, etc.)

Adding a New Rule

TheHeck is easily extensible via TOML rules, which do not require recompiling.

Just create a .toml file in ~/.config/theheck/rules/:

[[rules]]
name = "sl_ls"
match.script_regex = "^sl"
replace.template = "{{script_replace('sl', 'ls')}}"

For a detailed guide on how to create, test, and use TOML or Go rules, see: Creating Custom Rules

Configuration

TheHeck can be configured via a TOML file, environment variables, or command-line flags.

For a full reference of all settings and environment variables, see: Configuration Guide

Quick Start

Initialize the config file:

theheck init

The configuration is stored at ~/.config/theheck/settings.toml. You can also use the interactive configuration tool:

theheck config

Command-Line Flags

  • --yes, -y - Skip confirmation and run the first suggestion
  • --debug - Enable debug output
  • --help, -h - Show help

Usage

The best way to use TheHeck is with shell integration. After running eval "$(theheck alias)", you can simply type heck after any failed command:

$ git puls
git: 'puls' is not a git command. See 'git --help'.

$ heck
# TheHeck will suggest and execute: git pull
# The corrected command is added to your shell history

Features:

  • Reads the failed command from shell history automatically
  • Executes the corrected command immediately
  • Adds corrected command to shell history
  • Works with command_not_found_handler for instant corrections

Manual Usage

You can also call theheck directly with a command:

theheck "git puls"

Basic Usage

theheck <failed_command>

Example:

$ git puls
# git: 'puls' is not a git command. See 'git --help'.
$ theheck git puls
# Shows: git pull

Auto-Confirmation

theheck --yes git puls
# Immediately outputs: git pull

Debug Mode

theheck --debug git puls
# Shows which rules matched and why

Running Tests

make test

Or for specific packages:

go test ./pkg/config/
go test ./pkg/rules/