#shell #command #typo #correction #zsh #found #not-found

app suggest-command-not-found

未找到 shell 命令的错别字更正

8 个版本

0.1.7 2023年5月12日
0.1.6 2023年4月26日

#1 in #typo

Download history 11/week @ 2024-03-09 1/week @ 2024-03-16 13/week @ 2024-03-30

每月下载量 77

MIT 许可证

5KB
58 代码行

suggest-command-not-found crates.io 版本 crates.io 下载

未找到 shell 命令的错别字更正

ScreenShot

用法

  1. 安装 suggest-command-not-found
    $ cargo install suggest-command-not-found
    
  2. command_not_found_handler 添加到您的 ~/.zshrc
    command_not_found_handler() {
      if command -v suggest-command-not-found &> /dev/null; then
        exec suggest-command-not-found $@
      else
        echo "zsh: command not found: $@"
      fi
    }
    
    如果您使用 Bash,请更新您的 ~/.bash_profile
    command_not_found_handle() {
      if command -v suggest-command-not-found &> /dev/null; then
        exec suggest-command-not-found $@
      else
        echo "bash: command not found: $@"
      fi
    }
    
  3. 输入一个错别字
    $ carog new mypj
    Error: command not found: "carog" new mypj
       ==> Did you mean "cargo"?
    
    $ notacommand
    Error: command not found: "notacommand"
    
    $ echo $?
    127
    

依赖关系

~0–10MB
~53K SLoC