{"id":35693980,"url":"https://github.com/AsfhtgkDavid/theshit","last_synced_at":"2026-01-11T20:00:29.933Z","repository":{"id":305937534,"uuid":"1024493726","full_name":"AsfhtgkDavid/theshit","owner":"AsfhtgkDavid","description":"A command-line utility that automatically detects and fixes common mistakes in shell commands with a focus on speed and usability.","archived":false,"fork":false,"pushed_at":"2025-12-30T19:04:50.000Z","size":774,"stargazers_count":20,"open_issues_count":6,"forks_count":4,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-02T22:28:30.298Z","etag":null,"topics":["collaborate","github"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AsfhtgkDavid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-22T19:37:14.000Z","updated_at":"2026-01-02T20:36:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"74cb2b70-136e-4f6d-9b08-0d00dba0e97f","html_url":"https://github.com/AsfhtgkDavid/theshit","commit_stats":null,"previous_names":["asfhtgkdavid/theshit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AsfhtgkDavid/theshit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AsfhtgkDavid%2Ftheshit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AsfhtgkDavid%2Ftheshit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AsfhtgkDavid%2Ftheshit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AsfhtgkDavid%2Ftheshit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AsfhtgkDavid","download_url":"https://codeload.github.com/AsfhtgkDavid/theshit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AsfhtgkDavid%2Ftheshit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28321259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T18:42:50.174Z","status":"ssl_error","status_checked_at":"2026-01-11T18:39:13.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collaborate","github"],"created_at":"2026-01-06T00:00:56.925Z","updated_at":"2026-01-11T20:00:29.908Z","avatar_url":"https://github.com/AsfhtgkDavid.png","language":"Rust","funding_links":[],"categories":["Project Categories"],"sub_categories":[],"readme":"# The Shit [![Version][version-badge]][version-link] [![MIT License][license-badge]](LICENSE.md) [![codecov][codecov-badge]][codecov-link]\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"theshit-demo.gif\" alt=\"theshit demo\" /\u003e\n\u003c/p\u003e\n\nA command-line utility that automatically fixes common shell command errors, inspired\nby [thefuck](https://github.com/nvbn/thefuck). When you type a command incorrectly, just run `shit` and it will suggest\nthe correct command.\n\n## Table of Contents\n\n- [Installation](#installation)\n    - [From crates.io](#from-cratesio)\n    - [Build from source](#build-from-source)\n- [Usage](#usage)\n    - [Setup](#setup)\n    - [Basic usage](#basic-usage)\n- [Supported Shells](#supported-shells)\n- [Built-in Rules](#built-in-rules)\n- [Custom Rules](#custom-rules)\n    - [Writing Python rules](#writing-python-rules)\n    - [Disabling rules](#disabling-rules)\n- [Configuration](#configuration)\n- [Tricks and Tips](#tricks-and-tips)\n- [Contributing](#contributing)\n- [Bug Reports](#bug-reports)\n- [License](#license)\n\n## Installation\n\n### From crates.io\n\n```bash\ncargo install theshit\n```\n\n### Build from source\n\n```bash\ngit clone https://github.com/AsfhtgkDavid/theshit.git\ncd theshit\ncargo build --release --no-default-features\n```\n\nThe binary will be available at `target/release/theshit`. You can install it to your system with\n`cargo install --path .` or copy it to a directory in your `$PATH`.\n\n## Usage\n\n### Setup\n\nFirst, set up the alias in your shell:\n\n```bash\n# This will add the necessary alias to your shell configuration and create the base rules\ntheshit setup\n```\n\nOr specify a custom alias name:\n\n```bash\ntheshit setup myfix\n```\n\nAfter setup, restart your shell or source your configuration file.\n\n### Basic usage\n\nWhen a command fails, just type `theshit` (or your custom alias):\n\n```bash\n$ sl\nbash: sl: command not found\n$ shit\nls [enter/↑/↓/Ctrl+C]\n```\n\nThe tool will suggest corrections. Use:\n\n- **Enter** to execute the selected command\n- **↑/↓** to navigate between suggestions\n- **Ctrl+C** to cancel\n\n## Supported Shells\n\n- **Bash**\n- **Zsh**\n- **Fish**\n\n## Built-in Rules\n\n### Native Rules (Rust)\n\n| Rule               | Description                                                   | Example                                        |\n|--------------------|---------------------------------------------------------------|------------------------------------------------|\n| `sudo`             | Adds `sudo` to commands that failed with permission errors    | `mkdir /etc/config` → `sudo mkdir /etc/config` |\n| `to_cd`            | Fixes typos in the `cd` command                               | `cs /home` → `cd /home`                        |\n| `unsudo`           | Removes `sudo` from commands that shouldn't be run as root    | `sudo npm install` → `npm install`             |\n| `mkdir_p`          | Adds `-p` flag to `mkdir` when parent directories don't exist | `mkdir a/b/c` → `mkdir -p a/b/c`               |\n| `cargo_no_command` | Fixes cargo subcommand typos                                  | `cargo biuld` → `cargo build`                  |\n\n### Permission Patterns\n\nThe `sudo` rule recognizes these error patterns:\n\n- \"permission denied\"\n- \"eacces\"\n- \"operation not permitted\"\n- \"must be run as root\"\n- \"authentication is required\"\n- And many more...\n\n## Custom Rules\n\n### Writing Python rules\n\nCreate a Python file in `~/.config/theshit/fix_rules/active/` with the following structure:\n\n```python\ndef match(command: str, stdout: str, stderr: str) -\u003e bool:\n    \"\"\"\n    Determine if this rule should be applied to the failed command.\n    \n    Args:\n        command: The original command that failed\n        stdout: Standard output from the failed command\n        stderr: Standard error from the failed command\n    \n    Returns:\n        True if this rule should fix the command, False otherwise\n    \"\"\"\n    return \"your condition here\"\n\ndef fix(command: str, stdout: str, stderr: str) -\u003e str:\n    \"\"\"\n    Generate the corrected command.\n    \n    Args:\n        command: The original command that failed\n        stdout: Standard output from the failed command\n        stderr: Standard error from the failed command\n    \n    Returns:\n        The corrected command string\n    \"\"\"\n    return \"your fixed command here\"\n```\n\n#### Example: Git branch typo rule\n\n```python\n# ~/.config/theshit/fix_rules/active/git_branch_typo.py\nimport re\n\ndef match(command: str, stdout: str, stderr: str) -\u003e bool:\n    return (command.startswith(\"git\") and \n            \"did you mean\" in stderr and\n            \"branch\" in command)\n\ndef fix(command: str, stdout: str, stderr: str) -\u003e str:\n    # Extract suggested branch name from git error message\n    match = re.search(r\"did you mean '([^']+)'\", stderr)\n    if match:\n        suggested_branch = match.group(1)\n        return re.sub(r\"branch \\S+\", f\"branch {suggested_branch}\", command)\n    return command\n```\n\n### Disabling rules\n\nTo disable a rule temporarily, add `.bak` to its filename:\n\n```bash\n# Disable the sudo rule\nmv ~/.config/theshit/fix_rules/active/sudo.native ~/.config/theshit/fix_rules/active/sudo.native.bak\n\n# Disable a Python rule\nmv ~/.config/theshit/fix_rules/active/my_rule.py ~/.config/theshit/fix_rules/active/my_rule.py.bak\n```\n\nTo permanently disable a rule, move it to the additional rules directory:\n\n```bash\nmv ~/.config/theshit/fix_rules/active/sudo.native ~/.config/theshit/fix_rules/additional/\n```\n\n## Configuration\n\nConfiguration files are stored in `~/.config/theshit/`:\n\n```\n~/.config/theshit/\n├── fix_rules/\n│   ├── active/          # Rules that are currently enabled\n│   │   ├── sudo.native\n│   │   ├── to_cd.native\n│   │   └── custom_rule.py\n│   └── additional/      # Disabled rules\n│       └── disabled_rule.py\n```\n\n## Tricks and Tips\n\n### 1. Shell Integration\n\nFor the best experience, add this to your shell configuration:\n\n**Bash (~/.bashrc):**\n\n```bash\n# Run theshit on double ESC\nbind '\"\\e\\e\": \"theshit\\n\"'\n```\n\n**Zsh (~/.zshrc):**\n\n```zsh\n# Run theshit on double ESC\nbindkey -s '\\e\\e' 'theshit\\n'\n```\n\n### 2. Alias Expansion\n\nThe tool automatically expands aliases before processing, so if you have:\n\n```bash\nalias ll='ls -la'\n```\n\nAnd you run `ll /nonexistent`, the tool will process `ls -la /nonexistent`.\n\n### 3. Custom Alias Names\n\nYou can use any alias name:\n\n```bash\ntheshit setup fix\ntheshit setup oops\ntheshit setup dammit\n```\n\n### 4. Environment Variables\n\nThe tool sets these environment variables during execution:\n\n- `SH_SHELL`: Current shell (bash/zsh)\n- `SH_PREV_CMD`: The previous command that failed\n- `SH_SHELL_ALIASES`: Available shell aliases\n\n## Contributing\n\nPlease see [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to this project.\n\nFor a quick overview of the project architecture, you can\nuse  [Code2tutorial](https://code2tutorial.com/tutorial/711fc304-35d9-4c8a-a743-c3ddf1c3d09e/index.md).\n\n## Bug Reports\n\nIf you encounter a bug or have a feature request, please [open an issue](https://github.com/AsfhtgkDavid/theshit/issues)\nwith:\n\n1. **Environment information:**\n    - OS and version\n    - Shell and version\n    - Rust version (if building from source)\n\n2. **Steps to reproduce:**\n    - The original command that failed\n    - The error message\n    - Expected vs actual behavior\n\n3. **Relevant logs:**\n    - Include any error messages from `theshit`\n    - Shell configuration if relevant\n\n4. **For rule-related issues:**\n    - Output of the failing command\n    - Contents of `~/.config/theshit/fix_rules/active/` if using custom rules\n\n### Common Issues\n\n**Issue: Custom Python rules not working**\n\n- Check that the rule file has both `match()` and `fix()` functions\n- Ensure the file is in the `active` directory\n- Verify Python syntax with `python -m py_compile your_rule.py`\n\n**Issue: Alias not found after setup**\n\n- Restart your shell or run `source ~/.bashrc` / `source ~/.zshrc`\n- Check that the alias was added to the correct configuration file\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n[version-badge]: https://img.shields.io/crates/v/theshit\n\n[version-link]: https://crates.io/crates/theshit\n\n[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg\n\n[codecov-badge]: https://codecov.io/github/asfhtgkdavid/theshit/graph/badge.svg?token=016D8DZWLG\n\n[codecov-link]: https://codecov.io/github/asfhtgkdavid/theshit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAsfhtgkDavid%2Ftheshit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAsfhtgkDavid%2Ftheshit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAsfhtgkDavid%2Ftheshit/lists"}