python中thefuck包的安裝和使用(每個python程式設計師都應該安裝的神器)
thefuck誕生
你是不是經常在終端敲錯命令?敲錯命令,刪掉重敲,很煩有沒有?當你一再敲錯的時候,內心一定很崩潰,一定在默唸FUCK!
。就這樣thefuck
神器就誕生了。thefuck
不僅能修復字元輸入順序的錯誤,在很多別的你想說fuck
的情況下,thefuck
依然有效,反正只要你因為命令的問題報錯,就請fuck
一下。
thefuck的使用方法(超級簡單)
示例
1、命令拼寫不對
-
# 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
-
Python 3.4.2
2、命令輸錯
-
# git brnch
-
git: 'brnch' is not a git command. See 'git --help'.
-
Did you mean this?
-
branch
-
# fuck
-
git branch
-
* master
3、許可權不夠
-
# 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
-
[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
-
python get-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
更多安裝及使用方法檢視Github
專案地址:https://github.com/nvbn/thefuck。
2、配置
-
#編輯bashrc配置檔案
-
vim ~/.bashrc
-
#在檔案尾加入一行給thefuck取別名fuck
-
eval "$(thefuck --alias fuck)"
-
#使生效
-
source ~/.bashrc
最後使用fuck
命令來糾正命令列拼寫錯誤。
更新到最新的 thefuck 的方法非常簡單: sudo pip3 install thefuck --upgrade