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

猜你喜欢

转载自blog.csdn.net/myli_binbin/article/details/83619568