一個開源的命令列神器——「thefuck」
簡介
你是不是經常在終端敲錯命令?敲錯命令,刪掉重敲,很煩有沒有?當你一再敲錯的時候,內心一定是崩潰的,一定在默唸What The FUCK!。就這樣thefuck神器就誕生了。thefuck不僅能修復字元輸入順序的錯誤,在很多別的你想說fuck的情況下,thefuck依然有效,反正只要你因為命令的問題報錯,就請fuck一下。
專案地址
https://github.com/nvbn/thefuck
功能展示

示例
1、命令拼寫不對
# puthon
No command'puthon'found, did you mean:
Command'python'frompackage'python-minimal'(main)
Command'python'frompackage'python3'(main)
zsh: commandnotfound: puthon
# fuck
python
Python3.4.2
2、命令輸錯
# git brnch
git:'brnch'isnot a git command. See'git --help'.
Did you meanthis?
branch
# fuck
git branch
* master
3、許可權不夠
# apt-get install vim
E: Could not openlockfile /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
[sudo] password for nvbn:
Reading package lists... Done
安裝
1、安裝thefuck
執行以下命令:
#CentOS系統
yum-y update && yum -y install gcc
wget https://bootstrap.pypa.io/get-pip.py
pythonget-pip.py && yum -y install python-devel
sudo -H pip install thefuck
#Ubuntu/Debian系統
sudo apt update
sudo apt install python3-dev python3-pip
sudo pip3 install thefuck
更多安裝及使用方法檢視官網
2、配置
#編輯bashrc配置檔案
vim ~/.bashrc
#在檔案尾加入一行給thefuck取別名fuck
eval"$(thefuck --alias fuck)"
#使生效
source~/.bashrc
最後使用fuck命令來糾正命令列拼寫錯誤。
更新到最新的 thefuck 的方法非常簡單: sudo pip3 install thefuck --upgrade
溫馨提示,請謹慎使用此命令,執行的時候千萬不要讀出來。用習慣了容易成為口頭禪。

歡迎關注我的公眾號:【菜鳥要飛】 ,面試寶典、學習路線、原始碼分享等等你來學