每个Linux运维开发肯定敲错过命令。有时候做一些紧急的任务,敲错了,得到了错误的结果或异常,是不是想说
fuck。看完本教程你就可以在敲错命令后输入fuck,保证你心情舒畅得到正确的结果。

官方示例
开源地址:https://github.com/nvbn/thefuck
macOS安装
brew install thefuck
Ubuntu安装
sudo apt update
sudo apt install python3-dev python3-pip python3-setuptools python-pip
pip3 install thefuck --user
FreeBSD安装
pkg install thefuck
通用python环境下
pip install thefuck
在
.bash_profile、.bashrc文件中配置以下命令
> vim .bashrc
eval $(thefuck --alias)
eval $(thefuck --alias FUCK)

image-20221012203655164
我想进入python命令行,结果敲了pytho就回车了。没关系输入fuck。
root@开源日记:~# pytho
Command 'pytho' not found, did you mean:
command 'python' from deb python3
command 'python' from deb python
command 'python' from deb python-minimal
Try: apt install <deb name>
root@开源日记:~# fuck
python [enter/↑/↓/ctrl+c]
Python 2.7.17 (default, Jul 1 2022, 15:56:32)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

首次
git push提交,一般都需要和远程分支关联,但是很多时候只会敲上git push没关系输入fuck
root@开源日记:~# 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
root@开源日记:~# fuck
git push --set-upstream origin master [enter/↑/↓/ctrl+c]
Counting objects: 100, done.
查看当前目录下的文件会用
ls,但是敲快了成了sl,没关系输入fuck
root@开源日记:~# sl
Command 'sl' not found, but can be installed with:
apt install sl
root@开源日记:~# fuck
ls [enter/↑/↓/ctrl+c]
123.txt 开源日记.txt
经常启动mysql搞错,关系输入fuck
root@开源日记:~# systemstl start mysql
Command 'systemstl' not found, did you mean:
command 'systemctl' from deb systemd
Try: apt install <deb name>
root@开源日记:~# fuck
systemctl start mysql [enter/↑/↓/ctrl+c]

The Fuck试图将前面的命令与规则相匹配。如果找到匹配项,则使用匹配的规则创建一个新命令并执行
az_cli- 修复拼写错误的命令,例如az providers;cargo– 运行cargo build而不是cargo;cargo_no_command- 修复错误命令,例如cargo buid;cat_dir–当您尝试访问目录时替换cat为;ls``catcd_correction– 拼写检查和纠正失败的 cd 命令;cd_cs– 更改cs为cd;cd_mkdir– 在 cd 进入目录之前创建目录;cd_parent– 更改cd..为cd ..;chmod_x– 添加执行位;choco_install– 为巧克力包装添加通用后缀;更多功能广大网友可以继续挖掘。