相信大家每个人都有敲错过命令的时候,把
python
输入成puthon
. 手速过快把ls -alh
输入成ls a-lh
等等等,这时候是不是想拍一下键盘说一声fuck
.
有一个同事就开发了一个
thefuck
的项目,可纠正先前控制台命令中的错误。让我们能愉快的工作下去.
在 macOS 或 Linux 上,您可以通过Homebrew安装The Fuck:
brew install thefuck
在 FreeBSD 上,使用以下命令安装The Fuck:
pkg install thefuck
Centos系统/Ubuntu系统
pip install thefuck
#编辑bashrc配置文件vim ~/.bashrc#在文件尾加入一行给thefuck取别名fuckeval "$(thefuck --alias fuck)"#使生效source ~/.bashrc
忘记加sudo,fuck一下就好了.
apt-get install vimE: 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?➜ fucksudo apt-get install vim [enter/↑/↓/ctrl+c][sudo] password for nvbn:Reading package lists... Done
➜ git pushfatal: 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➜ fuckgit push --set-upstream origin master [enter/↑/↓/ctrl+c]Counting objects: 9, done....
python
敲成puthon
➜ puthonNo command 'puthon' found, did you mean: Command 'python' from package 'python-minimal' (main) Command 'python' from package 'python3' (main)zsh: command not found: puthon➜ fuckpython [enter/↑/↓/ctrl+c]Python 3.4.2 (default, Oct 8 2014, 13:08:17)...
其实TheFuck的原理就是规则匹配(正则表达式),如果找到匹配规则的命令,则创建一个命令给用户选择或直接运行。
cat_dir - 当你尝试cat目录的时候,用ls替换cat;
cd_correction – 拼写检查和纠正失败的cd命令;
cd_mkdir – 在进入目录之前创建目录;
cd_parent – 更改 cd.. 为cd ..;
dry – 修复类似的重复问题:git git push;
fix_alt_space – 用空格字符代替Alt + Space;
# 还有很多可以参考https://github.com/nvbn/thefuck#how-it-works
如有侵权,请联系删除
好文推荐