Do you often type wrong commands in the terminal , in fact, this is because the damn terminal does not cooperate and cannot understand what you mean. At this time, even when you make mistakes repeatedly, your heart must be broken, and you must be silently saying "...". And now, it's time for your terminal to wake up! |
A dude named @liamosaur couldn't help but let out an angry yell at his terminal and put it into practice:
Inspired by this, a programmer named Vladimir Iakovlev delivered a fatal blow to the damn terminal! He and 90 of his angry pals have built an artifact called "thefuck"!
When your terminal doesn't type commands as you imagine , please fuck it!
When your terminal doesn't execute commands with sudo as you think, fuck it!
When your terminal doesn't know to fill in the obvious parameters, please fuck it!
When you enter the wrong command:
➜ 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) ...
When you forget to enter a parameter:
➜ 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. ...
When you enter wrong parameters:
➜ git brnch git: 'brnch' is not a git command. See 'git --help'. Did you mean this? branch ➜ fuck git branch [enter/↑/↓/ctrl+c] * master
When you forget to type 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 [enter/↑/↓/ctrl+c] [sudo] password for nvbn: Reading package lists... Done ...
Well, I think you definitely want to have such an artifact, so please...
I want this artifact!
Environmental requirements
First, you need these:
- python (2.7+ or 3.3+)
- pip
- python-dev
Install
Then, on a different operating system (yes, wherever Python is available):
On Ubuntu it can be installed via apt:
sudo apt update sudo apt install python3-dev python3-pip pip3 install --user thefuck
Install using Homebrew on OS X:
brew install thefuck
On other systems, as long as you have
pip
Just do:
pip install --user thefuck
For more Linux distributions, you can see here.
set alias
The name of the package installed above is: "thefuck" - don't ask me why it can't just be called "fuck". So, you can set an alias:
Bash
Add the following line to .bashrc or .bash_profile (for OSX):
eval "$(thefuck --alias)"
ZSH
Add the following lines to .zshrc:
eval "$(thefuck --alias)"
For other shells , including powershell, you can refer to here.
Of course, I think I'd prefer to call it "kao" instead. :D
To make the alias take effect immediately, you need to use the source command, such as:
source ~/.bashrc 或 source ~/.zshrc
How did it make me think clearly?
thefuck This package contains hundreds of matching rules, which are specially used to modify your mistakes, and modify them to the way they should be thoughtfully!
For those specific rules, you can read them here, or try them out.
Of course, if you often make some unique mistakes, you can also create your own rules, and you might as well submit a pull request to this project to find friends who are as unique as you.
What are you waiting for? Hurry up and pretend !