一个名叫草泥马的项目:thefuck

开发者都或多或少接触过 linux 接触过命令行,当然肯定也都被命令行狠狠地“fuck”过。我很多时候都是微不足道的原因导致了命令行出错,例如将 python 输入成 ptyhon,例如将 ls -alh 输入成 ls a-lh而导致出错,这个时候我会想说:“fuck”。

起源

开发 thefuck 的这位同仁,恐怕也经常会有这种不和谐的情况。因此开发了这个软件 thefuck。

thefuck 不仅仅能修复字符输入顺序的错误,在很多别的你想说“fuck”的情况下,thefuck 依然有效。

例如以下情况。

案例

任何情况下你想说“我操”,你都可以用得到 thefuck。

例如:

ls 和 sl

使用过 ubuntu 的开发者很多都知道有这么一条命令:sl。这条命令是在你将 ls 错误地输成 sl 时,会在屏幕上快速驶过一辆火车。当然,有了 thefuck,sl 似乎也可以退休了。

➜ sl
The program 'sl' is currently not installed. You can install it by typing:
sudo apt-get install sl
➜ fuck
ls #修正
a.go                   b.php           dockerui      jekyll-casper  main.go  PureBlog   sss.png                              typecho
a.php                  c-hash          Font-Awesome  jekyll-pure    mili     signal.c   TeamTalk                             upload
bii-ubuntu-64_3_0.deb  Dockerfile      harmony       JekyllPure     ngircd   signal.c~  tingyun-agent-php-latest.x86_64.deb  web.go
blog                   Dockerfile.bak  hashmap       kasper         php-src  sss.jpg    tipi                                 zerver

忘记 sudo

➜ 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
[sudo] password for nvbn:
Reading package lists... Done

操作 git

➜ 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
Counting objects: 9, done.
...

错输命令

➜ 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
Python 3.4.2 (default, Oct  8 2014, 13:08:17)
...

选项修正

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

Did you mean this?
    branch

➜ fuck
git branch
* master

其他

thefuck 还有其他很多种用法,就等着你去发现。

安装

安装需求

  • python (2.7+ or 3.3+)

  • pip

  • python-dev

安装方法

  1. 可以使用 pip 安装:sudo pip install thefuck
    或者使用 OS X、Ubuntu、Arch 的包管理器安装

  2. 安装后配置bash:

    alias fuck='eval $(thefuck $(fc -ln -1)); history -r'

    Zsh、Fish 和 PowerShell 的 配置方法见这里

更新

更新到最新的 thefuck 的方法非常简单:

sudo pip install thefuck --upgrade

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值