Last update at :2024-05-05,Edit by888u
Source: https://linux.cn/article-8471-1.html
Do you often type the wrong commands in the terminal? In fact, this is because the damn terminal is not cooperative and cannot understand what you mean.
Whenever this happens, even when you repeatedly make mistakes, your heart must be broken, and you must be reciting "..." silently.
And now, it’s time to wake up your terminal!
A buddy named @liamosaur couldn't help but roared angrily at his terminal and put it into practice:
Inspired by this, a programmer named Vladimir Iakovlev delivered a fatal blow to this damn terminal! He and his 90 angry friends built an artifact called "thefuck"!
When your terminal doesn't type commands the way you imagined, fuck it!
When your terminal doesn't execute commands with sudo as you thought, fuck it!
When your terminal doesn't know to fill in the obvious parameters, 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 parameters:
➜ 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 incorrect 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 enter 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
...
If life is so unsatisfactory, you can continue to "teach" it:
➜ aptget install vim
No command 'aptget' found, did you mean:
Command 'apt-get' from package 'apt' (main)
zsh: command not found: aptget
➜ fuck
aot-get install vim [enter/ctrl-c]
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?
Still need permission? Come again!
➜ fuck
sudo apt-get install vim [enter/ctrl-c]
[sudo] password for nvbn:
Reading package lists... Done
Building dependency tree... 0%
... ...
I want this artifact!
environmental needs
First, you need these:
python (2.7+ or 3.3+)
pip
python-dev
Installation
Then, on a different operating system (yes, wherever Python is available):
Installation via apt on Ubuntu:
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:
pip install --user thefuck
Set an alias
The name of the software package installed above is: "thefuck" - don't ask me why it can't just be called "fuck". So, you can set the alias:
Bash
Add the following lines 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, please refer to here.
Of course, I think I would prefer to call it "kao". :D
To make the alias take effect immediately, you need to use the source command, such as:
source ~/.bashrc
or
source ~/.zshrc
How does it make my thoughts clear?
thefuck is a software package that contains hundreds of matching rules, specifically used to modify your mistakes and thoughtfully modify them to how they should be!
You can check here for the specific rules, or you can find out by trying them.
Of course, if you often make some unique mistakes, you can also create your own rules, and you may wish to 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!
Recommended site searches: in domain name, la domain name, foreign host, domain name registration, registered domain name, Beijing domain name registration, site group server, domain name, dynamic vps instant IP replacement, US host purchase,
发表评论