工具与资源github.com
The Fuck——纠正你上一条控制台命令
The Fuck – Correct your previous console command
2015 — 2018,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
thefuck 是一个开源命令行工具:当你输错命令(比如忘了加 sudo、拼写错误)后,输入 fuck 它会自动推断并纠正上一条命令。项目在 GitHub 上长期流行,多次登上 Hacker News 首页。
为什么经久不衰:它用幽默的名字解决了一个所有命令行用户都天天遇到的痛点,是“小工具解决真问题”的经典案例,至今仍是许多开发者的装机必备。
HN 评论精选
bash 自带的 !! 等历史展开快捷键可以覆盖很多场景
好主意。但对于没法装第三方工具的系统,值得了解一些 bash 标准快捷键:!^ 取上一条命令的第一个参数,!$ 取最后一个参数,!* 取全部参数,!! 是整条上一条命令。比如 apt-get install foo 之后忘了 sudo,直接输 sudo !! 即可。
csandreasen查看英文原文
Cool idea. For those systems where you don't have the option of adding a 3rd party tool, it's probably worth knowing some of the standard bash shortcuts. The easy to remember ones are: !^ - the first argument from the previous command !$ - the last argument from the previous command !* - all of the arguments from the previous command !! - the entire previous command For example: $ apt-get install foo # Crap $ sudo !!
自动纠错可能猜错命令,带来危险后果
有个用户的 issue 挺搞笑:他输入 fuck,工具把命令纠正成了 fsck,结果开始对已挂载的文件系统做检查,差点造成严重损坏。
c0achmcguirk查看英文原文
An issue that popped up for a user, kind of funny: https://github.com/nvbn/thefuck/issues/1 who@where:~$ fuck No fuck given who@where:~$ fuck fsck from util-linux 2.20.1 e2fsck 1.42.9 (4-Feb-2014) /dev/sda6 is mounted. WARNING!!! The filesystem is mounted. If you continue you ***WILL*** cause ***SEVERE*** filesystem damage. Do you really want to continue<n>? no check aborted.
Git 内置的 help.autocorrect 已提供类似功能
Git 其实已经有类似配置:help.autocorrect 可以在输入错误子命令时自动纠正并执行,默认只显示不执行。
manojlds查看英文原文
Git already has a config to do this: help.autocorrect Automatically correct and execute mistyped commands after waiting for the given number of deciseconds (0.1 sec). If more than one command can be deduced from the entered text, nothing will be executed. If the value of this option is negative, the corrected command will be executed immediately. If the value is 0 - the command will be just shown but not executed. This is the default. http://git-scm.com/docs/git-config
自动纠错可能把安全保护一起“纠正”掉,非常危险
演示了一个危险场景:rm -rf / 被系统的保护机制拦下后,输入 fuck 反而纠正成了 sudo rm -rf --no-preserve-root /,把保护也绕过去了。
Johnny555查看英文原文
[~user/]$ rm -rf / rm: it is dangerous to operate recursively on `/' rm: use --no-preserve-root to override this failsafe [~user/]$ fuck sudo rm -rf --no-preserve-root / fuck!
实用但命令名在正式场合容易尴尬,可自定义别名
我日常都在用,从忘加 sudo 到各种拼写错误都靠它。不过也有尴尬时刻——有次在投影仪前给团队和工程总监演示时输错命令后打了 fuck,引来无数注目。可以通过改 .bashrc 里的 alias 换掉这个命令名,但我没换!
madmax108查看英文原文
I use this regularly, for everything ranging from the forgotten sudo (instead of running "sudo !!") to typos across the board. But it does get me into interesting situations! Just the other day I was demo-ing something to my team + Director of Engg on the projector, and I ran an incorrect command, followed by "fuck" to fix it, leading to so many stares :P Just as an FYI, you can change the prompt from fuck to something else by changing your .bashrc eg.: eval "$(thefuck-alias fixit)" I'm not changing my alias though! ;)
历次讨论
同类还值得读
直接在浏览器中启动 Linux 内核
Boot a linux kernel right inside your browser.
Fabrice Bellard 的 JSLinux 页面,用 JavaScript 在浏览器里启动一个 Linux 内核,并提供一个可交互的终端环境。
工具与资源上首页 5 次 · 2011–2025bellard.orgHacker News 未公开功能与行为清单(2018)
A List of Hacker News's Undocumented Features and Behaviors (2018)
数据科学家 Max Woolf 整理的 Hacker News 未公开功能与行为清单,涵盖投票机制、排名算法、账号惩罚等社区运作细节。
工具与资源上首页 5 次 · 2019–2025github.comMapSCII:在终端中用盲文和 ASCII 渲染地图
MapSCII – Braille and ASCII map renderer for the console
MapSCII 是一个在命令行终端里渲染地图的开源工具,用盲文字符和 ASCII 字符把地理数据画成可交互浏览的字符地图。
工具与资源上首页 5 次 · 2017–2025github.com顶尖大学的免费在线课程
Free Online Courses from Top Universities
Open Culture 整理的一份免费在线课程合集,汇集了全球顶尖大学(如 MIT、斯坦福、耶鲁等)向公众开放的网络课程资源,涵盖音频、视频等多种形式。
工具与资源上首页 5 次 · 2010–2022openculture.com淘气字符串:容易引发用户输入问题的字符串清单
Naughty Strings: A list of strings likely to cause issues as user-input data
一个 GitHub 仓库,收录了大量容易让程序出问题的用户输入字符串,如特殊字符、emoji、SQL 注入片段、系统命令等,供开发者用于测试输入处理逻辑。
工具与资源上首页 4 次 · 2015–2020github.com