一个好玩的 terminal 插件

推荐一个好玩的终端插件,名字叫:thefuck。回想下每次把 git status 写成 git stats, git branch 写成 git brunch 的懊恼,虽然每次重新输入并不会花费太多时间,然而输错的瞬间你可能最容易脱口而出的就是 “fuck” 了。那么当输入有误时,假如你能任性的敲入 fuck,终端乖乖替你完成正确的输入,是不是很解气?

这就是 the fuck 插件的主要作用。

安装

brew install thefuck
Seems like fuck alias isn't configured!
Please put eval $(thefuck --alias) in your ~/.zshrc.
More details - https://github.com/nvbn/thefuck#manual-installation

好吧,按照提示,将 alias 内容拷贝到 zshrc 里,并让其生效。

下面是官方的几个例子:

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, use

    git push --set-upstream origin master

fuck
git push --set-upstream origin master [enter/↑/↓/ctrl+c]
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 [enter///ctrl+c]
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 [enter/↑/↓/ctrl+c]
* master

安装以及使用的细节在项目的 Github 地址 可以看到,支持诸多特性,你甚至可以自己定义规则。

comments powered by Disqus
返回 写的 拍的 标签