Reducing keyboard input can greatly improve the efficiency of programmers. the use of shortcut keys is a good example. Programmers often use terminals. Is there a similar & ldquo; shortcut key & rdquo; on the terminal that can improve our efficiency? The programmer's work is often related to the front and back. Therefore, this article demonstrates how to use the previous command to improve work efficiency. 1. use all the parameter methods of the previous command :! * Example: If I use hello.txt and bye.
Reducing keyboard input can greatly improve the efficiency of programmers. the use of shortcut keys is a good example. Programmers often use terminals. Is there a similar "shortcut key" on the terminal that can improve our efficiency? The programmer's work is often related to the front and back. Therefore, this article demonstrates how to use the previous command to improve work efficiency.
1. use all parameters of the previous command
Method:! *
Example: If I edit hello.txtand bye.txt, I want to use git add to add these two files. You can use: git add! *
2. use the last parameter of the previous command
Method:! $
ALT +.
ESC +.
The following two methods are automatically completed in terminal.
3. use the part of the last parameter in the previous command
Method:! -:
Example: I personally think this is useful because a lot of options are input in some commands, and the last one is the object that actually works. if you enter the option again, it will be troublesome.
4. use any part of the previous command
Method:ALT + +.
Num indicates the part of the previous command, starting from 0, for ls-shld hello.txt. ALT + 0 +. is ls. 1 is-shld
5. replace a part of the previous command
Method: replace foo with bar
^ Foo ^ bar is replaced with only one
!! : Gs/foo/bar replace all
6. previous command
Method:!!
Finally, we recommend a website to learn this. if you encounter a command that requires too many keyboard input, or if you guess there may be a better and more efficient way, you may wish to search for it on this website. in this way, you can accumulate and take some time to get the result: commandlinefu.com.
MORE: We often run a lot of long commands. at this time, you can view the command through history and then use it! (Command number in history ).