Improve Linux work efficiency - set the hotkey under the command prompt

zhaozj2021-02-16  56

One feature of Linux is that there is much more powerful, and the frequent input command is not only troublesome and the workload is large. Although you can use Tab to make your own input, or use Aliase to simplify the input of a command, but this does not fundamentally fundamentally Solve the problem of too many tap keys.

You can specify a combination of any command or command to a key on the keyboard, which can be Alt [A-Z],

Ctrl- [AZ], Alt Shift [AZ], F1-F12, Ctrl-F [1-12], ALT-F [1-12], Alt Shift F [1-12], there is more incredible What can even add "parameters" for the function key so that when you press the key, it will wait for you to enter the corresponding parameters and run different commands according to different parameters.

Of course, some hot bonds will be captured by the terminal, such as common CTRL-D / C / Q / Z, but it doesn't matter, the hot bond available can be used!

Define the configuration file of the hotkey as: / etc / inputrc or ~ / .inputrc, the format that defines the hotkey is as follows:

"": ""

The ASCII characters corresponding to the hotkey can be input by "pressing Ctrl-V, then press the hotkey". For example, the characters corresponding to Ctrl-g are ^ g, the characters corresponding to the ALT-P are ^ [p, Ctrl- The characters corresponding to Alt-h are ^ [^ h.

You can use / c instead of Alt, / m- / c instead of Alt, / m- / c, such as / cm = Ctrl-m, / m- / ch = alt-ctrl-m. Also available / e represents ^ [.

Let's take some basic hotkey definition, (here the letters in hot keys are not case sensitive):

"^ [-": "SU - / C-M" # Press Alt - Execute the su - command, the end / c-m indicates that the entered command is entered, and it can be read more simply in one / n.

"/ M- / c-g": "Gaim &> / dev / Null && Disown / C-M"

# Press Ctrl-Alt-g to open GAIM at the current shell and run independently, that is: even if you quit the shell, Gaim will not close

Some other combinations can be configured according to their own needs, even don't say much.

Everyone may feel that this definition is too messy, and it is difficult to remember, there is still a limit. This issue will be resolved later.

In general, we can use the up and down direction keys to find the list of command history, repeat the input command, but the direction is too far, such as> If frequent use, will delay a lot of time, and move the right hand Not very convenient, is there any way to transfer the function of the arrow keys to us often> Knock on the command? If you use Alt J = Down Arrow to find, Alt K = UP Arrow looks down

This can be done by defining a hotkey:

"/ EH": "^ [o" # move left

# Alt-h Move a character to the left, which is equivalent to Left Arrowgh, here ^ [OD, the ASCII character of the forward key, the input method is similar to the previous

"/ el": "^ [o" # Move Right

# Alt-l Move a character to right, equivalent to Right Arrow

"/ ej": "^ [ob" # Move Up

# Alt-j move down, equivalent to UP Arrow "/ ek": "^ [oa" # Move Down

# Alt-k move, equivalent to Down Arrow

"/ ei": "^?" # left earse one character

# Alt-i delete a character to left, equivalent to Backspace

"/ EO": delete-char # Right Earse One Character

# Alt-o Delete a character to the right, equivalent to Delete

"/ en": Backward-Kill-Word # left kill one word

# Alt-n to delete a word left

"/ em": Kill-Word # Right Kill One Word

# Alt-m delete a word to the right

"/ EA": "^ [n ^ [n ^ [n ^ [n ^ [n ^ [n ^ [N" # kill to the head

# Alt-a delete the current location to the beginning, that is, how many alt-n (a-> ahead)

"/ ee": "^ [m ^ [m ^ [m ^ [m ^ [m ^ [m ^ [m" # kill to the head

# Alt-E Delete the current position to the end, that is, how many alt-m (e-> end)

"/ EP": INSERT-LAST-Argumem "

# Alt-p insert the last parameter (P -> Paste)

"/ ew": Forward-Word

# System default ALT-F (Forward) Skip to the current word word, if you have already in the words, jump to the next word (right side) word

"/ EQ": Backward-Word

# System Default ALT-B (Backward) Jump to the current word word, if you have already in the word, jump to the previous word (one word on the left)

I found that f and b are too far, it is inconvenient, and I will change alt-q, Alt-W, but ALT-F / B can be used.

Almost do not have to leave the main keyboard area, and move the cursor, delete characters, delete words, and the upper and lower history commands look up> in one, more convenient than before. However, it will be somewhat not used to it, just like VI, but I will be skilled in recentation.

The configuration of most of Linux is based on the configuration file. Generally, change the configuration file of a service, to make it take effect, but also to restart the service directly or an attached daemon. Don't you feel that "every vi /etc/xxx.conf is also the service xxx restart / rel." Do you do this very cumbersome? If you want to configure more services, do you have to debug it? And usually use Linux, it is difficult to terminate or start a service process from time to time, and the number of input commands is also a lot. If you specify a hotkey for each service, it seems unlikely. If we give a hotkey as a basic key, the corresponding service is its "parameter", what is it?

For example, give Alt-s (s -> start) to the basic key of the launch service, the first 2 characters of the service name are start "parameters", so you can start a service as follows:

"/ ESSM": "Service SMB Start / N"

# / es = alt-s, SM = SMB,

# Ie: Press Alt-S to keep up with the re-enter SM (at this time, the input SM does not appear on the terminal), you can start the SAMBA service process, do not worry, press the button and the input "parameter" Time delay problem, you press Alt-S, then go to the outside, then enter SM, then enter SM, still can. "/ ESHT": "Service httpd start / n" # ht = httpd, start Apache service

Similarly, we give

Alt-D (D -> Shutdown) is the basic key of the stop service

Alt-r (r -> restart) Basic key for restart services

Alt-t (t -> status) is the basic key for viewing service status

Alt-c (c -> configure) is the basic key of the primary configuration file corresponding to the service

Such as: "/ ECNF": "vi / etc / exports / n" # alt-c nf Opens the configuration file for NFS

"/ ECSM": "vi /etc/samba/smb.conf/n" # alt-c sm opens the SMB configuration file

If a service (such as SSH) has 2 configuration files, you can add a number thereafter, such as:

"/ ECSSH1": "VI / ETC / SSH / SSHD_CONFIG / N" # Open SSHD server configuration file

"/ ECSSH2": "VI / ETC / SSH / SSH_CONFIG / N" # Open SSHD Client Profile

What if you want to execute an application? You can use Alt-x to do basic keys (x -> execcute) such as:

"/ EXGA": "Gaim & &> / Dev / Null && Dism && Clean / N"

"/ exxm": "XMMS & &> / Dev / Null && Disown && Clean / N"

"/ EXVM": "VMware & &> / Dev / Null && Disown && Clean / N" "/ Exna": "Nautilus &> / dev / null && Disown && clean / N"

and many more....

Up to now we can implement the following functions in one of the functions of one key 2 characters:

1. Execute the specified application

2. Start | Restart | Close | Specified Service Process

3. View the status of the specified service

4. Open the specified configuration file for the specified service

Roughly sorted, it is still more chaotic, please don't mind, if there is any leak or mistake in the text, please correct it!

转载请注明原文地址:https://www.9cbs.com/read-19656.html

New Post(0)