1. 程式人生 > >python中thefuck包的安裝和使用(每個python程式設計師都應該安裝的神器)

python中thefuck包的安裝和使用(每個python程式設計師都應該安裝的神器)

thefuck誕生

你是不是經常在終端敲錯命令?敲錯命令,刪掉重敲,很煩有沒有?當你一再敲錯的時候,內心一定很崩潰,一定在默唸FUCK!。就這樣thefuck神器就誕生了。thefuck不僅能修復字元輸入順序的錯誤,在很多別的你想說fuck的情況下,thefuck依然有效,反正只要你因為命令的問題報錯,就請fuck一下。

thefuck的使用方法(超級簡單)

請輸入圖片描述

示例

1、命令拼寫不對

 
  1. # puthon

  2. No command 'puthon' found, did you mean:

  3. Command 'python' from package 'python-minimal' (main)

  4. Command 'python' from package 'python3' (main)

  5. zsh: command not found: puthon

  6.  
  7. # fuck

  8. python

  9. Python 3.4.2

2、命令輸錯

 
  1. # git brnch

  2. git: 'brnch' is not a git command. See 'git --help'.

  3.  
  4. Did you mean this?

  5. branch

  6.  
  7. # fuck

  8. git branch

  9. * master

3、許可權不夠

 
  1. # apt-get install vim

  2. E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)

  3. E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

  4.  
  5. # fuck

  6. sudo apt-get install vim

  7. [sudo] password for nvbn:

  8. Reading package lists... Done

  9.  

安裝

1、安裝thefuck
執行以下命令:

 
  1. #CentOS系統

  2. yum -y update && yum -y install gcc

  3. wget https://bootstrap.pypa.io/get-pip.py

  4. python get-pip.py && yum -y install python-devel

  5. sudo -H pip install thefuck

  6.  
  7. #Ubuntu/Debian系統

  8. sudo apt update

  9. sudo apt install python3-dev python3-pip

  10. sudo pip3 install thefuck

更多安裝及使用方法檢視Github專案地址:https://github.com/nvbn/thefuck

2、配置

 
  1. #編輯bashrc配置檔案

  2. vim ~/.bashrc

  3. #在檔案尾加入一行給thefuck取別名fuck

  4. eval "$(thefuck --alias fuck)"

  5. #使生效

  6. source ~/.bashrc

最後使用fuck命令來糾正命令列拼寫錯誤。

 

更新到最新的 thefuck 的方法非常簡單: sudo pip3 install thefuck --upgrade