Reduce keyboard input, can greatly improve the programmer's work efficiency, the use of shortcut keys is a good example. Programmers often use terminals. So is there a similar "shortcut key" on the terminal that can improve our efficiency? The programmer's work is often connected. So, this article shows you how to use the previous command to increase your productivity.
1. Use all parameters of the previous command
Method:!*
Example: If I edit hello.txt and bye.txt, then I want to add these two files using git Add. You can use: Git add!*
2. Use the last parameter of the previous command
Method:!$
ALT +.
ESC +.
Two of the following methods, terminal will be automatically filled
3. Use the part of the previous command except for the last parameter
Method:!-:
Example: Personally think this is more useful, because some commands in the middle will enter a lot of options, the last one is the actual role of the object, if you enter the option again, it will appear troublesome.
4. Use any part of the previous command
Method: ALT + +.
Where Num represents the first of the previous command, starting at 0 for LS-SHLD Hello.txt. ALT +0+. is LS. 1 is-shld.
5. Replace one part of the previous command
Method: replace Foo with bar
^foo^bar replaces only one
!!:gs/foo/bar Replaces all
6. Previous command
Method:!!
MORE: We often run a lot of very long commands, this time, you can view the command through the history, and then use! (Command number in history).