Linux terminal may be one of the most frequently used tools in Linux. There is a handy command line to greatly improve work efficiency.
Let's take a look:
1. Command Line prompt symbol
Control the hint by defining a set of predefined values and controlling the PS1 and PS2 environment variables.
Echo $ PS1
The modification takes effect directly. For example, let the command line display the command line number.
Export PS1 = "#" to display the command line number
You can use man Bash to search for key world: PS1.
2. Tab completion
The full-text set name, completion command, and completion environment variables are supported. Double press tab key.
3. Jump to and edit the central position of the command line
For example, you can jump a word forward or backward from the current position (cursor) to the beginning or end of the line if the shortcut key in VIM is used.
Many functions are supported, which can be viewed through bind-P. You can also save the changes to the. Bash. RC file.
Commonly used: GET parameters that were last run, such as C-1, M-. (that is, the first parameter of the last run command)
M-. The last parameter of the last run is obtained by default.
M-# (Alt-shift-3) can comment out the command.
Move C-a/c-e to the header or end of the line.
C-W deletes the previous word. Of course, you can set these keys to suit your needs.
Command line extensions: M-* '(insert-completions)
You can extend ls T * to LS test.txt test. cpp. (assume that the current directory has a file name that starts with test)
'C-x * '(press Ctrl-X first, then press *) or complete (Glob-expand-word)
Ls *. txt will be extended to LS test.txt log.txt (assuming that the current directory only has a file name suffixed with txt)
"\ C-G": Abort "\ c-x \ c-G": Abort "\ e \ c-G": Abort "\ c-J ": accept-line "\ c-M": Accept-line # Alias-expand-line (not bound) # arrow-key-prefix (not bound) # backward-byte (not bound) "\ c-B": backward-char "\ EOD": backward-char "\ e [d ": backward-char "\ c-h": backward-delete-char "\ c -? ": Backward-delete-char" \ c-x \ c -? ": Backward-kill-line" \ e \ c-h ": backward-kill-word" \ e \ c -? ": Backward-kill-word" \ Eb ": backward-word" \ e <": beginning-of-History" \ c-": beginning-of-line "\ eoh": beginning-of-line "\ e [H": beginning-of-line "\ c-XE ": call-last-KBD-macro "\ EC": Capitalize-word "\ c-]": character-search "\ e \ c-]": character-search-backward "\ c-l": Clear-screen "\ c-I": complete "\ e": complete "\ e! ": Complete-command" \ E/": complete-FILENAME" \ E @ ": complete-hostname" \ E {": complete-into-braces" \ e ~ ": Complete-username" \ e $ ": complete-variable # copy-backward-word (not bound) # copy-forward-word (not bound) # copy-region-as-kill (not bound) # dabbrev-expand (not bound) "\ c-d": delete-char "\ e [3 ~ ": Delete-Char # Delete-Char-or-List (not bound)" \ e \ ": delete-horizontal-space" \ e -": digit-argument "\ E0": digit-argument "\ e1": digit-argument "\ E2": digit-argument "\ E3": digit-argument "\ E4 ": digit-argument "\ E5": digit-argument "\ E6": digit-argument "\ E7": digit-argument "\ E8": digit-argument "\ E9 ": digit-argument "\ c-x \ c-V": Display-shell-version "\ c-xa": Do-lowercase-version "\ c-xB ": do-lowercase-version" \ C-XC ": Do-lowercase-version" \ c-XD ": Do-lowercase-version" \ c-XE ": do-lowercase-version "\ c-XF": Do-lowercase-version "\ c-XG": Do-lowercase-version "\ c-XH ": do-lowercase-version "\ c-Xi": Do-lowercase-version "\ c-XJ": Do-lowercase-version "\ c-XK ": do-lowercase-version "\ c-XL": Do-lowercase-version "\ c-XM": Do-lowercase-version "\ c-XN ": do-lowercase-version "\ c-xo": Do-lowercase-version "\ c-XP": Do-lowercase-ve Rsion "\ c-XQ": Do-lowercase-version "\ c-XR": Do-lowercase-version "\ c-XS ": do-lowercase-version "\ c-XT": Do-lowercase-version "\ c-xu": Do-lowercase-version "\ c-XV ": do-lowercase-version "\ c-XW": Do-lowercase-version "\ c-xx": Do-lowercase-version "\ c-XY ": do-lowercase-version "\ c-xz": Do-lowercase-version "\ ea": Do-lowercase-version "\ Eb ": do-lowercase-version "\ EC": Do-lowercase-version "\ ed": Do-lowercase-vers Ion "\ ee": Do-lowercase-version "\ EF": Do-lowercase-version "\ eg": Do-lowercase-version "\ eh ": do-lowercase-version "\ ei": Do-lowercase-version "\ EJ": Do-lowercase-version "\ EK": Do-lowercase-version "\ El ": do-lowercase-version "\ em": Do-lowercase-version "\ en": Do-lowercase-version "\ EP": Do-lowercase-version "\ eq ": do-lowercase-version "\ Er": Do-lowercase-version "\ es": Do-lowercase-version "\ et": Do-lowercase -Version "\ EU": Do-lowercase-version "\ EV": Do-lowercase-version "\ ew": Do-lowercase-version "\ ex ": do-lowercase-version "\ ey": Do-lowercase-version "\ ez": Do-lowercase-version "\ El ": downcase-word # dump-functions (not bound) # dump-macros (not bound) # dump-variables (not bound) "\ e \ c-I ": dynamic-complete-History "\ c-x \ c-e": Edit-and-execute-command # emacs-editing-mode (not bound) "\ c-x) ": End-KBD-macro" \ E>": End-of-History "\ c-e": end-of-line "\ EOF": end-of-line "\ e [F ": end-of-line "\ c-x \ c-X": Exchange-point-and-mark # forward-backward-delete-CHAR (not bound) # Forward-byte (not bound) "\ c-F": Forward-char "\ EOC": Forward-char "\ e [C ": forward-char "\ c-s": Forward-search-History "\ EF": Forward-word "\ eg ": glob-complete-word "\ c-x *": Glob-expand-word "\ c-XG ": glob-list-expansions # history-and-alias-expand-line (not Bound) "\ e ^": history-expand-line # History-search-backward (not bound) # History-search-Forward (not bound) "\ e #": insert-comment "\ E *": insert-Completions "\ e. ": insert-last-argument" \ E _ ": insert-last-argument # Kill-line (not bound)" \ c-k ": kill-region # Kill-whole-line (not bound) "\ ed": Kill-word # Magic-space (not bound) # menu-complete (not bound) # menu-complete-backward (not bound) "\ c-n": Next-histor Y "\ eob": Next-History "\ e [B": Next-History "\ en ": non-incremental-forward-search-history # non-incremental-forward-search-history-again (not bound) "\ EP ": non-incremental-reverse-search-history # non-incremental-reverse-search-history-again (not bound) # Old-menu-complete (not bound) "\ c-o": Operate-and-get-next # overwrite-mode (not bound) "\ c-X! ": Possible-command-Completions" \ e = ": Possible-Completions" \ e? ": Possible-Completions" \ c-x/": Possible-filename-Completions" \ c-x @ ": Possible-hostname-Completions" \ c-x ~ ": Possible-username-Completions" \ c-x $ ": Possible-variable-Completions" \ c-P ": Previous-History" \ EOA ": previous-History "\ e [A": Previous-History "\ c-Q": quoted-Insert "\ c-V ": quoted-insert # redraw-current-line (not bound) "\ c-x \ c-r": re-read-init-file "\ c-r ": reverse-search-History "\ e \ c-r": Revert-line "\ Er": Revert-line "": Self-Insert "! ": Self-Insert" \ "": Self-Insert "#": Self-Insert "$": Self-Insert "%": Self-Insert "&": self-Insert "'": Self-Insert "(": Self-Insert ")": Self-Insert "*": Self-Insert "+": Self-Insert ", ": Self-Insert"-": Self-Insert ". ": Self-Insert"/": Self-Insert" 0 ": Self-insert" 1 ": Self-Insert" 2 ": Self-Insert" 3 ": self-Insert "4": Self-Insert "5": Self-Insert "6": Self-Insert "7": Self-Insert "8 ": self-Insert "9": Self-Insert ": ": Self-Insert"; ": Self-Insert" <": Self-Insert" = ": Self-Insert"> ": Self-Insert "? ": Self-Insert" @ ": Self-Insert" A ": Self-Insert" B ": Self-Insert" C ": Self-Insert" D ": self-Insert "E": Self-Insert "F": Self-Insert "G": Self-Insert "H": Self-Insert "I ": self-Insert "J": Self-Insert "K": Self-Insert "L": Self-Insert "M": Self-Insert "N ": self-Insert "O": Self-Insert "p": Self-Insert "Q": Self-Insert "R": Self-Insert "S ": self-Insert "T": Self-Insert "U": Self-Insert "v": Self-Insert "W": Self-Insert "X": Self-Insert "Y": Self-Insert "Z": Self-Insert "[": Self-Insert "\": Self-Insert "]": self-Insert "^": Self-Insert "_": Self-Insert "'": Self-Insert "A": Self-Insert "B ": self-Insert "C": Self-Insert "D": Self-Insert "E": Self-Insert "F": Self-Insert "G ": self-Insert "H": Self-Insert "I": Self-Insert "J": Self-Insert "K": Self-Insert "L ": self-Insert "M": Self-Insert "N": Self-Insert "O": Self-Insert "p": Self-Insert "Q ": Self-Insert" R ": Self-Insert" S ": Self-Insert" T ": Self-Insert" U ": Self-Insert" v ": self-Insert "W": Self-Insert "X": Self-Insert "Y": Self-Insert "Z": Self-Insert "{": self-Insert "|": Self-Insert "}": Self-Insert "~ ": Self-Insert" \ 200 ": Self-Insert" \ 201 ": Self-Insert" \ 202 ": Self-Insert" \ 203 ": self-Insert "\ 204": Self-Insert "\ 205": Self-Insert "\ 206": Self-Insert "\ 207": Self-Insert "\ 210 ": self-Insert "\ 211": Self-Insert "\ 212": Self-Insert "\ 213": Self-Insert "\ 214": Self-Insert "\ 215 ": self-Insert "\ 216": Self-Insert "\ 217": Self-Insert "\ 220": Self-Insert "\ 221": Self-Insert "\ 222 ": self-Insert "\ 223": Self-Insert "\ 224": Self-Insert "\ 225": Self-Insert "\ 226": Self-Insert "\ 227 ": self-Insert "\ 230": Self-Insert "\ 231": Self-Insert "\ 232": Self-Insert "\ 233": Self-Insert "\ 234 ": self-Insert "\ 235": Self-Insert "\ 236": Self-Insert "\ 237": Self-Insert "": Self-Insert "success "¡": self-Insert "into": Self-Insert "£": Self-Insert "€": Self-Insert "¥": Self-Insert "− ": self-Insert "§": Self-Insert "â": Self-Insert "": Self-Insert "into": Self-Insert "«": self-Insert "values": Self-Insert "values": Self-Insert "°": Self-Insert "± ": self-Insert "²": Self-Insert "values": Self-Insert "values": Self-Insert "µ": Self-Insert" values "¶": self-Insert "·": Self-Insert "into": Self-Insert "into": Self-Insert "°": Self-Insert "»": self-Insert "values": Self-Insert "à ": self-Insert "á": Self-Insert" â ": Self-Insert" into ": Self-Insert" ä": Self-Insert "": self-Insert "into": Self-Insert "ç": Self-Insert" è ": Self-Insert" é ": Self-Insert" ": self-Insert "into": Self-Insert "into": Self-Insert "í": Self-Insert" into ": Self-Insert" ": self-Insert "values": Self-Insert "N": Self-Insert "values": Self-Insert "ó": Self-Insert "values ": self-Insert "Ignore": Self-Insert "ö": Self-Insert" × ": Self-Insert" ø ": Self-Insert" Ignore ": self-Insert "ú": Self-Insert" into ": Self-Insert" U ": Self-Insert" into ": Self-Insert" ": self-Insert "into": Self-Insert "à": Self-Insert "á": Self-Insert" â ": Self-Insert" ": self-Insert "ä": Self-Insert" into ": Self-Insert" into ": Self-Insert" ç ": Self-Insert" è ": self-Insert "é": Self-Insert "into": Self-Insert "í ": self-Insert "values": Self-Insert "N": Self-Insert "values ": self-Insert "ó": Self-Insert "lower": Self-Insert "lower": Self-Insert "ö": Self-Insert" lower ": self-Insert "ø": Self-Insert "into": Self-Insert "ú": Self-Insert" into ": Self-Insert" ü ": self-Insert "plugin": Self-Insert "\ c-@": set-mark "\ e ": set-mark # shell-backward-kill-word (not bound) # shell-backward-word (not bound) "\ e \ c-e ": shell-expand-line # shell-forward-word (not bound) # shell-kill-word (not bound) # Skip-CSI-sequence (not bound) "\ c-X (": Start-KBD-macro # tab-insert (not bound) "\ E &": Tilde-expand "\ c-t ": transpose-chars "\ et": transpose-words # tty-status (not bound) "\ c-x \ c-u": Undo "\ c -_": undo # Universal-argument (not bound) # Unix-filename-rubout (not bound) "\ c-u": Unix-line-discard "\ c-W ": unix-word-rubout "\ EU": upcase-word # vi-append-EOL (not bound) # vi-append-mode (not bound) # vi-Arg-digit (not bound) # vi-back-to-indent (not bound) # vi-bword (not bound) # vi-change-case (not bound) # vi-change-CHAR (not bound) # vi-change-to (not bound) # vi-Char-search (not bound) # vi-column (not bound) # vi-complete (not bound) # vi-delete-To (not bound) # vi-editing-mode (not bound) # vi-end-word (not bound) # vi-EOF-maybe (not bound) # vi-eword (not bound) # vi-eword (not bound) # vi-fetch-history (not bound) # vi-first-print (not bound) # vi-fword (not bound) # vi-fword (not bound) # vi-Goto-mark (not bound) # vi-insert-Beg (not bound) # vi-Insertion-mode (not bound) # vi-match (not bound) # vi-movement-mode (not bound) # vi-next-word (not bound) # vi-overstrike (not bound) # vi-overstrike-delete (not bound) # vi-Prev-word (not bound) # vi-put (not bound) # vi-Redo (not bound) # vi-Replace (not bound) # vi-rubout (not bound) # vi-search-again (not bound) # vi-set-mark (not bound) # vi-SUBST (not bound) # vi-Tilde-expand (not bound) # vi-yank-Arg (not bound) # vi-yank-To (not bound) "\ c-y": Yank "\ e. ": yank-last-Arg" \ E _ ": yank-last-Arg" \ e \ c-y ": yank-Nth-Arg" \ ey ": yank-pop
4. Alias
Alias. for commonly used custom commands, you can use the shellout method to encapsulate them, or the simplest is the alias.
5. Configuration File
All of the above are put in the configuration file to avoid one modification at a time. Put it in. bashrc, and call bashrc.
You can also put this file on the cloud and use one Ubuntu to synchronize the configuration files between different computers. In this way, even if all the machines are re-installed, there is no need to worry about the loss of the quota file or modify it.
We strongly recommend that you do this once and sharpen the tool first for public interest :)
Reference:
Http://www.kerneltravel.net/newbie/bash_readline.htm