【 thefuck 安装与使用】Linux 终端自动纠错工具:一头GitHub上的“草泥马“ - thefuck,妈妈再也不用担心我打错命令行了!
目录
快速安装使用
.1.简介
2.安装
3.配置
4.补充官方盗料参考
快速安装使用
快速安装使用,四步即可:
#Ubuntu/Debian系统
sudo apt update
sudo apt install python3-dev python3-pip
sudo pip3 install thefuck
#编辑bashrc配置文件
vim ~/.bashrc
#在文件尾加入一行给thefuck取别名fuck
eval "$(thefuck --alias fuck)"
#使生效
source ~/.bashrc#其他#
#修正三条命令前的错误 - fuck 3
#新到最新的 thefuck - sudo pip3 install thefuck --upgrade

1. 简介
thefuck 是一个开源的命令行工具,用于自动纠正终端中的错误命令。它通过分析最近执行的命令和错误信息,提供一个或多个可能的正确命令,用户可以选择自动执行或手动确认。

更多示例:
➜ 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 [enter/↑/↓/ctrl+c]
[sudo] password for nvbn:
Reading package lists... Done
...
➜ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, usegit push --set-upstream origin master➜ fuck
git push --set-upstream origin master [enter/↑/↓/ctrl+c]
Counting objects: 9, done.
...
2. 安装
#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。
3.配置
#编辑bashrc配置文件
vim ~/.bashrc
#在文件尾加入一行给thefuck取别名fuck
eval "$(thefuck --alias fuck)"
#使生效
source ~/.bashrc
最后使用fuck命令来纠正命令行拼写错误。
4. 补充
-
历史修正
#thefuck 可以使用历史记录来更正以前的命令。例如,如果你想修正三条命令前的错误$ fuck 3 -
更新到最新的 thefuck 的方法:
sudo pip3 install thefuck --upgrade -
自定义部分配置示例
#thefuck的配置文件位于 ~/.config/thefuck/settings.py。你可以在这里修改一些默认设置,例如: #这个参数指定了 thefuck 应用的规则列表。thefuck 会根据这些规则来修正命令错误。如果没有特别指定,thefuck 会使用所有默认的规则 rules = [<list_of_rules>] require_confirmation = True wait_command = 3#例如: rules = ['sudo', 'no_command', 'missing_argument'] 表示只启用 'sudo'、'no_command' 和 'missing_argument' 这三个规则 #下列参数指定在修正命令之前是否需要用户确认。如果设置为 True,thefuck 会在执行修正命令之前提示用户确认。如果设置为 False,thefuck 会自动修正并执行命令而不需要用户确认 require_confirmation = True #wait_command = 3:这个参数指定 thefuck 在执行修正命令之前等待的时间(单位:秒)。这是为了给用户提供一个时间窗口来取消修正操作。如果你不需要这个延迟,可以设置为 0 wait_command = 0综上示例所述,这些设置帮助你更灵活地控制 thefuck 的行为
rules = ['sudo', 'no_command', 'missing_argument'] require_confirmation = True wait_command = 3编写自定义规则
可以编写自己的规则来处理特定的命令错误。在 ~/.config/thefuck/rules/ 目录中创建一个新的 Python 文件。 示例,创建一个 git_no_branch.py 文件:
from thefuck.utils import replace_argument, for_app from thefuck.specific.git import git_support@git_support def match(command):return ('error: src refspec master does not match any' in command.output) @git_support def get_new_command(command):return replace_argument(command.script, 'master', 'main')
参考资料
- GitHub - nvbn/thefuck: Magnificent app which corrects your previous console command.
- Thefuck - 华南理工大学科学计算公共服务平台用户手册
附上原文说明:
Requirements
- python (3.5+)
- pip
- python-dev
Back to Contents
Intallation
On macOS or Linux, you can install The Fuck via Homebrew:
brew install thefuckOn Ubuntu / Mint, install The Fuck with the following commands:
sudo apt update sudo apt install python3-dev python3-pip python3-setuptools pip3 install thefuck --userOn FreeBSD, install The Fuck with the following commands:
pkg install thefuckOn ChromeOS, install The Fuck using chromebrew with the following command:
crew install thefuckOn Arch based systems, install The Fuck with the following command:
sudo pacman -S thefuckOn other systems, install The Fuck by using :
pippip install thefuckAlternatively, you may use an OS package manager (OS X, Ubuntu, Arch).
# It is recommended that you place this command in your , , or other startup script:
.bash_profile``.bashrc``.zshrceval $(thefuck --alias) # You can use whatever you want as an alias, like for Mondays: eval $(thefuck --alias FUCK)Or in your shell config (Bash, Zsh, Fish, Powershell, tcsh).
Changes are only available in a new shell session. To make changes immediately available, run (or your shell config file like ).
source ~/.bashrc``.zshrcTo run fixed commands without confirmation, use the option (or just for short, or if you’re especially frustrated):
--yeah``-y``--hardfuck --yeahTo fix commands recursively until succeeding, use the option:
-rfuck -rBack to Contents
Updating
pip3 install thefuck --upgradeNoe: Alias functionality was changed in v1.34 of *The Fuck*
Uninstall
To remove The Fuck, reverse the installation process:
- erase or comment thefuck alias line from your Bash, Zsh, Fish, Powershell, tcsh, … shell config
Noe: Alias functionality was changed in v1.34 of *The Fuck*
Uninstall
To remove The Fuck, reverse the installation process:
- erase or comment thefuck alias line from your Bash, Zsh, Fish, Powershell, tcsh, … shell config
- use your package manager (brew, pip3, pkg, crew, pip) to uninstall the binaries
相关文章:
【 thefuck 安装与使用】Linux 终端自动纠错工具:一头GitHub上的“草泥马“ - thefuck,妈妈再也不用担心我打错命令行了!
目录 快速安装使用 . 1.简介 2.安装 3.配置 4.补充 官方盗料参考 快速安装使用 快速安装使用,四步即可: #Ubuntu/Debian系统 sudo apt update sudo apt install python3-dev python3-pip sudo pip3 install thefuck #编辑bashrc配置文件 vim ~/.bashrc…...
牛客网刷题 ——C语言初阶——BC112小乐乐求和
1.牛客网刷题 ——C语言初阶 牛客网:BC112小乐乐求和 小乐乐最近接触了求和符号Σ,他想计算的结果。但是小乐乐很笨,请你帮助他解答。 输入描述: 输入一个正整数n (1 ≤ n ≤ 109) 输出描述: 输出一个值,为求和结果。 示例1 输…...
【PyTorch】(基础七)---- 完整训练流程
首先要明确一点,我们在编写模型、训练和使用模型的时候通常都是分开的,所以应该把Module的编写以及train方法和test方法分开编写。 调用gpu进行训练:在网络模型,数据,损失函数对象后面都使用.cuda(&#x…...
01- 三自由度串联机械臂位置分析
三自由度串联机械臂如下图所示(d180mm,L1100mm,L280mm),利用改进DH法建模,坐标系如下所示: 利用改进DH法建模,该机器人的DH参数表如下所示: 对该机械臂进行位置分析&…...
Flutter实现可拖拽操作Draggable
文章目录 1. Draggable 控件的构造函数主要参数: 2. Draggable 的工作原理3. 常见用法示例 1:基本的拖拽控件解释:示例 2:与 DragTarget 配合使用解释: 4. Draggable 的回调详解5. 总结 Draggable 是 Flutter 中一个用…...
Vue BPMN Modeler流程图
1、参考地址 git clone https://github.com/evanyangg/vue-bpmn-modeler.git 2、安装bpmn.js npm install bpmn-js --save 3、使用bpmn.js <template><div class"containers"><div class"canvas" ref"canvas"></div&g…...
写在公司40周年前夕
日子太快了,来这里工作六年多了。现在才知道原来入职的公司只是母公司的一小点。刚来一年就碰到疫情,三年疫情之后就迎来亏损,而后就是变了董事长,换了总经理。 这圣诞前,所有的子分又换了一把手。动作之大,…...
Python调用Elasticsearch更新数据库
文章目录 Elasticsearch介绍Python调用Elasticsearch更新数据库 Elasticsearch介绍 Elasticsearch是一个基于Lucene的搜索引擎,它提供了一个分布式、多租户能力的全文搜索引擎,具有HTTP web接口和无模式的JSON文档。Elasticsearch是用Java开发的&#x…...
测试基础之测试分类
软件测试是确保软件产品满足预期功能、性能和用户体验要求的关键环节。它的主要目的是通过系统化的方法发现并修复软件中的缺陷,从而提高软件的质量和可靠性。在软件开发生命周期的不同阶段执行测试,以尽早发现潜在的错误或类型,早期发现缺陷…...
太阳能LED路灯智能控制系统(论文+源码)
1系统的功能及方案设计 本次课题为太阳能LED路灯智能控制系统,其系统整体架构如图2.1所示,太阳能板通过TP4056充电模块给锂电池进行充电,电池通过HX3001升压模块进行升压到5V给整个控制系统进行供电,控制系统由AT89C52单片机作为…...
文本数据处理
文本数据处理 一、数据转换与错误处理 (一)运维中的数据转换问题 在计算机审计及各类数据处理场景中,数据转换是关键步骤,涉及将被审计单位或其他来源的数据有效装载到目标数据库,并明确标示各表及字段含义与关系。…...
Liunx环境下安装人大金仓数据库V8R6版本
Liunx环境下安装人大金仓数据库V8R6版本 一:硬件环境要求二:软件环境要求三:安装包准备四:检测和配置环境4.1:检查操作系统信息4.2 检查系统内存与存储空间 五:配置内核参数六:预安装工作6.1 创…...
Android使用PorterDuffXfermode模式PorterDuff.Mode.SRC_OUT橡皮擦实现马赛克效果,Kotlin(3)
Android使用PorterDuffXfermode模式PorterDuff.Mode.SRC_OUT橡皮擦实现马赛克效果,Kotlin(3) import android.content.Context import android.graphics.Bitmap import android.graphics.BitmapFactory import android.graphics.Canvas impor…...
python 怎么引入类
一、导入单个类 from fun import Dog dogDog(husike) dog.bark() 二、导入多个类 多个类之间用逗号分隔 from fun import Dog,Cat dogDog(husike) dog.bark() catCat(maomi) cat.catch_mouse() 三、导入整个模块 import fun dogfun.Dog(husike) dog.bark() catfun.Cat(maomi) …...
Day35汉明距离
两个整数之间的 汉明距离 指的是这两个数字对应二进制位不同的位置的数目。 给你两个整数 x 和 y,计算并返回它们之间的汉明距离。 class Solution {public int hammingDistance(int x, int y) {int cnt 0;while (Math.max(x, y) ! 0) {if ((x & 1) ! (y &…...
中文学习系统:客户服务与学习支持
3.1 系统可行性分析 开发一款程序软件不仅需要时间,也需要人力,物力资源。而进行可行性分析这个环节就是解决用户这方面的疑问,看看程序在当前的条件下是否可以进行开发。 3.1.1 技术可行性分析 此程序选用的开发语言是Java,这种编…...
华为麦芒5(安卓6)termux记录 使用ddns-go,alist
下载0.119bate1版,不能换源,其他源似乎都用不了,如果root可以直接用面具模块 https://github.com/termux/termux-app/releases/download/v0.119.0-beta.1/termux-app_v0.119.0-beta.1apt-android-5-github-debug_arm64-v8a.apk 安装ssh(非必要) pkg install openssh开启ssh …...
餐厅下单助手系统(Java+MySQL)
项目概览 餐厅下单助手系统是一个采用 Java 实现的小型食品订单管理系统,并且以 SwingUI 打造视觉界面,数据库提供。本系统分为商家和顾客两类体验,有效地给予简洁性能。可用做课程设计,参考学习。 技术栈 Java: 核心开发语言S…...
Go操作MySQL
连接 Go语言中的database/sql包提供了保证SQL或类SQL数据库的泛用接口,并不提供具体的数据库驱动。使用database/sql包时必须注入(至少)一个数据库驱动。 我们常用的数据库基本上都有完整的第三方实现。例如:MySQL驱动 下载依赖…...
Linux(Ubuntu/CentOS)配置开机自启动服务
systemd和systemctl的区别和联系 systemd:是现代Linux系统中的初始化系统和服务管理器。它主要负责系统引导和进程管理,支持并行化启动服务,并提供高级的服务管理和依赖控制。 systemctl:是systemd的命令行工具,用于与…...
浏览器访问 AWS ECS 上部署的 Docker 容器(监听 80 端口)
✅ 一、ECS 服务配置 Dockerfile 确保监听 80 端口 EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]或 EXPOSE 80 CMD ["python3", "-m", "http.server", "80"]任务定义(Task Definition&…...
大数据学习栈记——Neo4j的安装与使用
本文介绍图数据库Neofj的安装与使用,操作系统:Ubuntu24.04,Neofj版本:2025.04.0。 Apt安装 Neofj可以进行官网安装:Neo4j Deployment Center - Graph Database & Analytics 我这里安装是添加软件源的方法 最新版…...
Spark 之 入门讲解详细版(1)
1、简介 1.1 Spark简介 Spark是加州大学伯克利分校AMP实验室(Algorithms, Machines, and People Lab)开发通用内存并行计算框架。Spark在2013年6月进入Apache成为孵化项目,8个月后成为Apache顶级项目,速度之快足见过人之处&…...
智慧工地云平台源码,基于微服务架构+Java+Spring Cloud +UniApp +MySql
智慧工地管理云平台系统,智慧工地全套源码,java版智慧工地源码,支持PC端、大屏端、移动端。 智慧工地聚焦建筑行业的市场需求,提供“平台网络终端”的整体解决方案,提供劳务管理、视频管理、智能监测、绿色施工、安全管…...
中南大学无人机智能体的全面评估!BEDI:用于评估无人机上具身智能体的综合性基准测试
作者:Mingning Guo, Mengwei Wu, Jiarun He, Shaoxian Li, Haifeng Li, Chao Tao单位:中南大学地球科学与信息物理学院论文标题:BEDI: A Comprehensive Benchmark for Evaluating Embodied Agents on UAVs论文链接:https://arxiv.…...
ssc377d修改flash分区大小
1、flash的分区默认分配16M、 / # df -h Filesystem Size Used Available Use% Mounted on /dev/root 1.9M 1.9M 0 100% / /dev/mtdblock4 3.0M...
条件运算符
C中的三目运算符(也称条件运算符,英文:ternary operator)是一种简洁的条件选择语句,语法如下: 条件表达式 ? 表达式1 : 表达式2• 如果“条件表达式”为true,则整个表达式的结果为“表达式1”…...
Vue2 第一节_Vue2上手_插值表达式{{}}_访问数据和修改数据_Vue开发者工具
文章目录 1.Vue2上手-如何创建一个Vue实例,进行初始化渲染2. 插值表达式{{}}3. 访问数据和修改数据4. vue响应式5. Vue开发者工具--方便调试 1.Vue2上手-如何创建一个Vue实例,进行初始化渲染 准备容器引包创建Vue实例 new Vue()指定配置项 ->渲染数据 准备一个容器,例如: …...
Java-41 深入浅出 Spring - 声明式事务的支持 事务配置 XML模式 XML+注解模式
点一下关注吧!!!非常感谢!!持续更新!!! 🚀 AI篇持续更新中!(长期更新) 目前2025年06月05日更新到: AI炼丹日志-28 - Aud…...
C++中string流知识详解和示例
一、概览与类体系 C 提供三种基于内存字符串的流,定义在 <sstream> 中: std::istringstream:输入流,从已有字符串中读取并解析。std::ostringstream:输出流,向内部缓冲区写入内容,最终取…...
