| docs | ||
| pkg | ||
| shell_configs | ||
| .envrc | ||
| .gitignore | ||
| .golangci.yml | ||
| .pre-commit-config.yaml | ||
| CONTEXT.md | ||
| default.nix | ||
| flake.lock | ||
| flake.nix | ||
| go.mod | ||
| go.sum | ||
| gomod2nix.toml | ||
| main.go | ||
| Makefile | ||
| priority_test.go | ||
| README.md | ||
| shell.nix | ||
| TODO.md | ||
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
heckafter any failed command - Supports Bash, Zsh, and Fish - Shell-specific integrations
- Configuration file support - TOML-based configuration (~/.config/theheck/settings.toml)
- Run
theheck initto generate a sample config file
- Run
- Interactive TUI - Beautiful terminal UI for selecting corrections
- Auto-confirmation mode - Use
--yesto 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
- Initialize your configuration:
theheck init
- 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
- Restart your shell or source your config:
source ~/.bashrc # or ~/.zshrc
- Now just type
heckafter 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 pointpkg/config: Configuration managementpkg/types: Core data structures (Command,Rule)pkg/rules: Collection of correction rules (168+ rules)pkg/shell: Shell interaction helperspkg/tui: Terminal UI componentspkg/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
Shell Integration (Recommended)
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_handlerfor 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/