https://github.com/nowayhecodes/wtf
https://github.com/nowayhecodes/wtf
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nowayhecodes/wtf
- Owner: nowayhecodes
- License: mit
- Created: 2024-11-07T13:46:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-08T12:24:37.000Z (over 1 year ago)
- Last Synced: 2025-12-26T09:58:11.385Z (6 months ago)
- Language: Go
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## WTF
A blazing fast command-line tool that automatically detects errors in previously executed console commands, suggests corrections, and provides an option to re-execute the corrected commands.
### Features
- 🚀 **Blazing Fast**: Reads only the last command from history without scanning the entire file
- 🎯 **Smart Suggestions**: Provides intelligent corrections for common typos and mistakes
- 🔄 **Quick Re-execution**: Re-run corrected commands with a simple confirmation
- ⚙️ **Customizable**: Define your own correction rules via configuration
- 🛡️ **Safe**: Asks for confirmation before executing any corrected command
- 🔌 **Shell Support**: Works with bash, zsh, and other common shells
### Installation
```bash
go install github.com/nowayhecodes/wtf@latest
```
Or quickly install using the install script:
```bash
curl -fsSL https://raw.githubusercontent.com/nowayhecodes/wtf/main/install.sh | sh
```
Or build from source:
```bash
git clone https://github.com/nowayhecodes/wtf.git
cd wtf
go build -o bin/wtf cmd/wtf/main.go
```
### Usage
After a failed command, simply run:
```bash
wtf
```
The tool will:
1. Detect the last failed command
2. Suggest a correction
3. Execute the corrected command with your confirmation
#### Examples
```bash
$ gti status
git: command not found
$ wtf
Did you mean: git status? [Y/n] y
# Executes: git status
```
```bash
$ grpe "pattern" file.txt
grpe: command not found
$ wtf
Did you mean: grep "pattern" file.txt? [Y/n] y
# Executes: grep "pattern" file.txt
```
### Configuration
Create a `.wtf.json` file in your home directory:
```json
{
"customRules": {
"gti": "git",
"sl": "ls"
},
"shellType": "bash",
"maxSuggestions": 3,
"levenThreshold": 2
}
```
#### Configuration Options
- `customRules`: Map of custom corrections
- `shellType`: Your shell type (bash, zsh)
- `maxSuggestions`: Maximum number of suggestions to show
- `levenThreshold`: Maximum edit distance for suggestions
### Development
Requirements:
- Go 1.22 or newer
- Make or Task (for build automation)
Setup:
```bash
# Clone the repository
git clone https://github.com/nowayhecodes/wtf.git
# Install dependencies
go mod download
# Run tests
go test ./...
# Build
task build
```
### Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
### License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
### Acknowledgments
- Inspired by various command-line tools that improve developer productivity
### Author
[@nowayhecodes](https://github.com/nowayhecodes)
### Support
If you like this project, please give it a ⭐️!