自动纠错的终端工具【The Fuck】“记性不好”人群的福利

引言

对于经常使用终端的人群,难免会因为命令的遗忘而导致报错,这时候就会问问度娘或者查询相关的文档资料,但是这样都会大幅度的影响开发者的任务进程,本文我介绍一款GitHub热门项目,TheFuck,去他的命令~哈哈哈哈
在这里插入图片描述

链接地址:https://github.com/nvbn/thefuck?tab=readme-ov-file#updating

官方示例

官方在文档中举了几个例子

More examples:

➜ apt-get install vim
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

➜ fuck
sudo apt-get install vim [enter/↑/↓/ctrl+c]
[sudo] password for nvbn:
Reading package lists… Done

➜ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin master

➜ fuck
git push --set-upstream origin master [enter/↑/↓/ctrl+c]
Counting objects: 9, done.

➜ puthon
No command ‘puthon’ found, did you mean:
Command ‘python’ from package ‘python-minimal’ (main)
Command ‘python’ from package ‘python3’ (main)
zsh: command not found: puthon

➜ fuck
python [enter/↑/↓/ctrl+c]
Python 3.4.2 (default, Oct 8 2014, 13:08:17)

➜ git brnch
git: ‘brnch’ is not a git command. See ‘git --help’.

Did you mean this?
branch

➜ fuck
git branch [enter/↑/↓/ctrl+c]

  • master
    ➜ lein rpl
    ‘rpl’ is not a task. See ‘lein help’.

Did you mean this?
repl

➜ fuck
lein repl [enter/↑/↓/ctrl+c]
nREPL server started on port 54848 on host 127.0.0.1 - nrepl://127.0.0.1:54848
REPL-y 0.3.1

安装

Installation

  • On macOS or Linux, you can install The Fuck via Homebrew:
    brew install thefuck

  • On Ubuntu / Mint, install The Fuck with the following commands:
    sudo apt update

  • sudo apt install python3-dev python3-pip python3-setuptools
    pip3 install thefuck --user

  • On FreeBSD, install The Fuck with the following commands:
    pkg install thefuck

  • On ChromeOS, install The Fuck using chromebrew with the following command:
    crew install thefuck

  • On Arch based systems, install The Fuck with the following command:
    sudo pacman -S thefuck

  • On other systems, install The Fuck by using pip:
    pip install thefuck

在这里插入图片描述

什么是 The Fuck?

The Fuck 是一个开源的命令行工具,它可以通过输入一个简单的命令(fuck),根据你的历史命令记录自动生成正确的命令并重新执行。例如:

$ git commti -m "fix typo"
git: 'commti' is not a git command. See 'git --help'.

$ fuck
git commit -m "fix typo"

你只需敲下 fuck,The Fuck 会帮你完成纠正!

为什么需要更新 The Fuck?

像其他开源工具一样,The Fuck 会定期发布新版本,修复已知问题并增加新功能。为了获得最新的功能体验和更好的性能,我们建议定期更新 The Fuck。

如何更新 The Fuck?

更新 The Fuck 非常简单,你只需要运行以下命令:

pip3 install thefuck --upgrade

这个命令会通过 Python 的包管理器 pip 更新 The Fuck 到最新版本。

注意事项:别名设置的变化
从 The Fuck v1.34 版本开始,工具对别名功能做了一些调整。如果你在更新后发现 The Fuck 无法正常工作,可能需要重新配置别名设置。

重新配置步骤如下:

打开你的 shell 配置文件(根据使用的 shell 不同,文件名称可能不同):

如果你使用的是 Bash,编辑 ~/.bashrc
如果你使用的是 Zsh,编辑 ~/.zshrc
在配置文件中添加以下内容:

bash
复制代码
eval $(thefuck --alias)
保存文件后,重新加载 shell 配置文件,使更改生效:

bash
复制代码
source ~/.bashrc

或者

source ~/.zshrc
完成这些步骤后,The Fuck 的别名功能将恢复正常工作。

总结

The Fuck 是开发者必备的命令行工具之一,能够显著提高效率。通过以上方法更新工具并配置别名,你将继续享受到它的便利功能。如果你还没有尝试过这款神器,不妨现在就安装试试!

更多关于 The Fuck 的详细信息,可以访问其 GitHub 项目主页🚀。

评论 109
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小馒头学python

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值