| Crates.io | super_snoofer |
| lib.rs | super_snoofer |
| version | 0.4.1 |
| created_at | 2025-02-28 13:13:00.54649+00 |
| updated_at | 2025-03-02 21:10:00.66293+00 |
| description | A fuzzy command finder that suggests similar commands when a typo is made |
| homepage | https://github.com/rakki194/super_snoofer |
| repository | https://github.com/rakki194/super_snoofer |
| max_upload_size | |
| id | 1572778 |
| size | 172,359 |
A fuzzy command finder for shells that suggests and executes similar commands when a typo is made. When you mistype a command, Super Snoofer will suggest the closest matching command and offer to execute it for you.
$ gti status
Awoo! ๐บ Did you mean `git status`? *wags tail* (Y/n/c) y
Running suggested command...
cargo install super_snoofer
git clone https://github.com/rakki194/super_snoofer.git
cd super_snoofer
cargo install --path .
Add this to your ~/.zshrc:
command_not_found_handler() {
super_snoofer "$1"
return $?
}
Add this to your ~/.bashrc:
command_not_found_handle() {
super_snoofer "$1"
return $?
}
Create a function in ~/.config/fish/functions/fish_command_not_found.fish:
function fish_command_not_found
super_snoofer "$argv[1]"
return $status
end
Super Snoofer works automatically once integrated with your shell. When you type a command that doesn't exist, it will:
super_snoofer <command> # Normal operation: suggest similar commands
super_snoofer --reset_cache # Clear the command cache but keep learned corrections
super_snoofer --reset_memory # Clear both the command cache and learned corrections
super_snoofer --history # Display your recent command corrections
super_snoofer --frequent-typos # Display your most common typos
super_snoofer --frequent-corrections # Display your most frequently used corrections
super_snoofer --clear-history # Clear your command history
super_snoofer --enable-history # Enable command history tracking
super_snoofer --disable-history # Disable command history tracking
super_snoofer --suggest # Suggest personalized shell aliases
# Basic suggestion and execution
$ carg build
Awoo! ๐บ Did you mean `cargo`? *wags tail* (Y/n/c) y
Running suggested command...
Compiling super_snoofer v0.1.0
# Teaching Super Snoofer a correction
$ gti status
Awoo! ๐บ Did you mean `got`? *wags tail* (Y/n/c) c
What's the correct command? git
Got it! ๐บ I'll remember that 'gti' means 'git'
[git output follows...]
# Using a learned correction
$ gti status
Awoo! ๐บ Did you mean `git`? *wags tail* (Y/n/c) y
Running suggested command...
[git output follows...]
# Rejecting a suggestion
$ pythn
Awoo! ๐บ Did you mean `python`? *wags tail* (Y/n/c) n
Command 'pythn' not found! ๐บ
Super Snoofer stores its data in:
~/.cache/super_snoofer_cache.json (if ~/.cache exists)~/.super_snoofer_cache.json (fallback)The cache contains:
Cache Management:
--reset_cache to manually clear the command cache--reset_memory to clear both cache and learned correctionsSuper Snoofer can learn from your corrections:
Command matching performance (on typical systems):
This means:
Super Snoofer uses the Levenshtein distance algorithm to find similar commands, with a configurable similarity threshold (currently set to 0.6). This means:
Super Snoofer finds commands by:
Scanning all directories in your PATH:
Special handling for Python:
Command caching:
Super Snoofer handles symbolic links intelligently:
python -> python3 -> python3.13)For example, if you have:
/usr/bin/python3.13 # Actual executable
/usr/bin/python3 -> python3.13
/usr/bin/python -> python3
Super Snoofer will suggest any of these names when you make a typo:
$ pythn
Awoo! ๐บ Did you mean `python`? *wags tail* (Y/n/c)
$ pythn3
Awoo! ๐บ Did you mean `python3`? *wags tail* (Y/n/c)
$ python313
Awoo! ๐บ Did you mean `python3.13`? *wags tail* (Y/n/c)
Contributions are welcome! Here's how you can help:
Please make sure to:
Run the test suite:
cargo test
The test suite includes:
This project is licensed under the MIT License - see the LICENSE file for details.
Command not found after installation
~/.cargo/bin is in your PATHsource ~/.bashrc or equivalentCache not updating
No suggestions appearing
If you encounter issues:
Super Snoofer now detects and includes shell aliases in its suggestions:
.bashrc and .bash_aliases.zshrc, .zsh_aliases, and Oh-My-Zsh custom aliasesconfig.fish and function-based aliases in ~/.config/fish/functions/Here are some useful examples of how Super Snoofer matches and suggests aliases:
# Example 1: Mistyped alias corrected to original alias
$ kk stutus # Where kk is an alias for kubectl
Awoo! ๐บ Did you mean `kk` (alias for `kubectl`)? *wags tail* (Y/n/c) y
Running suggested command: kubectl status
[command output follows...]
# Example 2: Mistyped alias suggesting multiple possibilities
$ dc ps # When you have both 'dc' and 'dco' as aliases
Awoo! ๐บ Did you mean `dc` (alias for `docker-compose`)? *wags tail* (Y/n/c) y
Running suggested command: docker-compose ps
[command output follows...]
# Example 3: Related aliases for common commands
$ giff # When you have git-related aliases
Awoo! ๐บ Did you mean `giff` (alias for `git diff --color`)? *wags tail* (Y/n/c) y
[git diff output follows...]
# Example 4: Learning a correction for a complex alias
$ dkr-rmall
Awoo! ๐บ Did you mean `dkr` (alias for `docker`)? *wags tail* (Y/n/c) c
What's the correct command? drm-all
Got it! ๐บ I'll remember that 'dkr-rmall' means 'drm-all'
[docker remove all containers output follows...]
# Example 5: Nested alias resolution
$ gs # Where gs is an alias for 'git status'
Awoo! ๐บ Did you mean `gs` (alias for `git status`)? *wags tail* (Y/n/c) y
[git status output follows...]
Alias matching in Super Snoofer provides several advantages:
Aliases are treated as first-class commands in Super Snoofer, meaning:
Super Snoofer is a good boy and will try to learn from your mistakes, by tracking the history of your command corrections and typos to provide smarter suggestions over time:
# View your command correction history
$ super_snoofer --history
๐บ Your recent command corrections:
1. gti โ git (17 times)
2. pythno โ python (8 times)
3. docekr โ docker (5 times)
...
# View most frequent typos
$ super_snoofer --frequent-typos
๐บ Your most common typos:
1. gti (17 times)
2. pythno (8 times)
3. docekr (5 times)
...
# View most frequent corrections
$ super_snoofer --frequent-corrections
๐บ Your most frequently used corrections:
1. git (22 times)
2. python (15 times)
3. docker (11 times)
...
# Clear your command history
$ super_snoofer --clear-history
Command history cleared successfully! ๐บ
# Enable command history tracking
$ super_snoofer --enable-history
Command history tracking is now enabled! ๐บ
# Disable command history tracking
$ super_snoofer --disable-history
super_snoofer --add-alias NAME [CMD] # Add shell alias (default: super_snoofer)
Command history tracking is now disabled! ๐บ
When making suggestions, Super Snoofer now prioritizes commands based on your usage history:
# When typing a command with multiple possible corrections
$ gti
Awoo! ๐บ Did you mean `git` (used 17 times)? *wags tail* (Y/n/c) y
Running suggested command...
The history data is stored in your cache file and is used to:
This feature helps Super Snoofer become more personalized to your workflow the more you use it.
Super Snoofer allows you to control whether command history is tracked:
You can toggle this setting using the following commands:
# Disable history tracking
$ super_snoofer --disable-history
Command history tracking is now disabled! ๐บ
# Enable history tracking
$ super_snoofer --enable-history
Command history tracking is now enabled! ๐บ
When history tracking is disabled:
--history, --frequent-typos, and --frequent-corrections commands will inform you that history tracking is disabledThis feature is useful if you:
The setting persists between Super Snoofer sessions.
Super Snoofer can analyze your command history and suggest helpful aliases to save you time:
# Generate a personalized alias suggestion
$ super_snoofer --suggest
You've mistyped 'gti' 17 times! Let's create an alias for that.
Suggested alias: g โ git
To add this alias to your shell configuration:
alias g='git'
Would you like me to add this alias to your shell configuration? (y/N)
The --suggest command analyzes your command history to:
This feature helps you create a more efficient workflow by automating the creation of aliases tailored to your specific typing patterns and command usage.
Super Snoofer v0.3.0 now corrects typos in the entire command line, not just the command name. For well-known commands, it can intelligently fix typos in subcommands, arguments, and flags:
# Correcting typos in git commands
$ gti sttaus
Awoo! ๐บ Did you mean `git status`? *wags tail* (Y/n/c) y
Running suggested command...
# Correcting typos in docker commands
$ dockr ps -a
Awoo! ๐บ Did you mean `docker ps -a`? *wags tail* (Y/n/c) y
Running suggested command...
# Correcting typos in cargo commands and flags
$ carg buld --relese
Awoo! ๐บ Did you mean `cargo build --release`? *wags tail* (Y/n/c) y
Running suggested command...
Super Snoofer v0.3.0 includes special handling for common Git command typos, such as:
# Common "status" typos
$ gti statuus
Awoo! ๐บ Did you mean `git status`? *wags tail* (Y/n/c) y
Running suggested command...
$ git satatus
Awoo! ๐บ Did you mean `git status`? *wags tail* (Y/n/c) y
Running suggested command...
$ git statsu
Awoo! ๐บ Did you mean `git status`? *wags tail* (Y/n/c) y
Running suggested command...
The correction engine is especially tuned for:
Super Snoofer uses a combination of pattern matching, Levenshtein distance, and special case handling to provide highly accurate corrections for these common command patterns.
Super Snoofer includes built-in knowledge about these common commands and their arguments:
When you enter a command with typos:
This works best with common CLI tools, but will fall back to simple command correction for other commands.
Super Snoofer includes intelligent shell detection and configuration management features that make it easy to add aliases and integrate with your system:
Super Snoofer can detect your current shell environment and provide appropriate configuration instructions:
# When suggesting an alias
$ super_snoofer --suggest
You've mistyped 'gti' 17 times! Let's create an alias for that.
Suggested alias: g โ git
To add this alias to your shell configuration:
alias g='git'
Would you like me to add this alias to your Zsh shell configuration? (y/N) y
Adding alias to /home/user/.zshrc
Added alias to your Zsh configuration! ๐บ Please run 'source /home/user/.zshrc' to use it.
Super Snoofer automatically detects and supports:
.bashrc.zshrcconfig.fishconfig.nu.kshrc.cshrc or .tcshrcSuper Snoofer creates appropriate shell-specific alias syntax based on your shell:
| Shell | Configuration File | Alias Format |
|---|---|---|
| Bash | ~/.bashrc | alias g='git' |
| Zsh | ~/.zshrc | alias g='git' |
| Fish | ~/.config/fish/config.fish | alias g 'git' |
| PowerShell | ~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1 | Set-Alias -Name g -Value git |
| Nushell | ~/.config/nushell/config.nu | alias g = git |
| Korn Shell | ~/.kshrc | alias g='git' |
| C Shell/TCSH | ~/.cshrc or ~/.tcshrc | alias g 'git' |
| Windows CMD | %USERPROFILE%\doskey.bat | doskey g=git |
Super Snoofer can not only suggest aliases but also handle the entire configuration process for you:
This makes it simple to integrate Super Snoofer with your workflow without needing to remember shell-specific configuration details.