有位名为 @liamosaur 的哥们就忍不住对本身的终端发出了愤怒的吼声,并付诸实践:html
受此启发, 一位名为 Vladimir Iakovlev 程序员对这个该死的终端发出了致命一击!他以及他的 90 位愤怒的小伙伴们打造出了一个名为 “thefuck” 的神器!python
当你的终端没有按你想象的输入命令时,请 fuck 它!linux
当你的终端没有按你想象的以 sudo 执行命令时,请 fuck 它!git
当你的的终端不知道填上显而易见的参数时,请 fuck 它!程序员
当你输入错误的命令时:shell
➜ 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 [enter/↑/↓/ctrl+c] Python 3.4.2 (default, Oct 8 2014, 13:08:17) ...
当你忘记输入参数时:vim
➜ git push fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin master ➜ fuck git push --set-upstream origin master [enter/↑/↓/ctrl+c] Counting objects: 9, done. ...
当你输入错误的参数时:bash
➜ git brnch git: 'brnch' is not a git command. See 'git --help'. Did you mean this? branch ➜ fuck git branch [enter/↑/↓/ctrl+c] * master
当你忘记输入 sudo时:this
➜ 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 ...
好了,我想你确定也想拥有这样的神器,请如此这般……操作系统
我要这个神器!
环境需求
首先,你须要这些:
安装
而后,在不一样的操做系统上(没错,有 Python 的地方就行):
在 Ubuntu 上能够经过 apt 安装:
sudo apt update sudo apt install python3-dev python3-pip pip3 install --user thefuck
OS X 上使用 Homebrew 来安装:
brew install thefuck
其它的系统上,只要你有
pip
就行:
pip install --user thefuck
更多的 Linux 发行版,能够看这里。
设置别名
上述安装的软件包名字是:“thefuck”——别问我为啥不能直接叫 “fuck”。因此,你能够设置个别名:
Bash
将下述行加入到 .bashrc或 .bash_profile(用于 OSX):
eval "$(thefuck --alias)"
ZSH
将下述行加入到 .zshrc:
eval "$(thefuck --alias)"
其它的 shell ,包括 powershell,能够参考这里。
固然,我以为我更喜欢给它起个别名叫 “kao”。:D
要让别名马上生效,你须要用 source 命令,如:
source ~/.bashrc 或 source ~/.zshrc
它是怎么让我念头通达的?
thefuck 这个软件包包含了上百个匹配规则,专门用来修改你的那些错误,贴心地将它们修改为应该的样子!
具体有那些规则,你能够看看这里,或者试试就知道了。
固然,若是你常常犯一些独特的错误,你也能够创建本身的规则,并且不妨提交拉取请求给这个项目,找到和你同样独特的小伙伴们。
还等什么?赶快去装啊!
本文地址:http://www.linuxprobe.com/ming-ling.html