在Ubuntu 20.04上打开控制台终端,试验了下面的快捷方式:
Bash Keyboard Shortcuts
光标移动:
Ctrl + a Go to the beginning of the line (Home)
Ctrl + e Go to the End of the line (End)
Alt + b Back (left) one word
Alt + f Forward (right) one word
Ctrl + f Forward one character
Ctrl + b Backward one character
Ctrl + xx Toggle between the start of line and current cursor position
Ctrl + Left Arrow / Alt + Left Arrow: Forward one word
Ctrl + Right Arrow / Alt + Right Arrow: Backward one word
内容编辑:
Ctrl + L Clear the Screen, similar to the clear command
Alt + Backspace: Delete the Word before the cursor.
Alt + d Delete the Word after the cursor.
Ctrl + d Delete character under the cursor
Ctrl + h Delete character before the cursor (Backspace)
Ctrl + w Cut the Word before the cursor to the clipboard.
Ctrl + k Cut the Line after the cursor to the clipboard.
Ctrl + u Cut/delete the Line before the cursor to the clipboard.
Ctrl + y Paste the last thing to be cut (yank)
Alt + t Swap current word with previous
Ctrl + t Swap the last two characters before the cursor (typo).
Esc + t Swap the last two words before the cursor. (Same as Alt+t)
Alt + u UPPER capitalize every character from the cursor to the end of the current word.
Alt + l Lower the case of every character from the cursor to the end of the current word.
Alt + c Capitalize the character under the cursor and move to the end of the word.
Alt + r Cancel the changes and put back the line as it was in the history (revert).
ctrl + _ Undo (Actually this is ctrl + shift + -)
TAB Tab completion for file/directory names
Ctrl + Shift + C : Copy
Shift + Insert : Paste
Ctrl + Shift + V : Paste
Note: The use of CtrlC to copy and CtrlV to paste from session-wide clipboard was introduced by Mac OS in 1983 and Microsoft Windows 3.x in 1990. (Earlier Windows versions (1.x and 2.x), as well as IBM OS/2, only supported the IBM CUA keys CtrlIns to copy and ShiftIns to paste; these shortcuts remain supported by all Windows versions.)
Note: Most modern terminal programs, like GNOME Terminal, use Ctrl+Shift+C and Ctrl+Shift+V for copy and paste.
Special keys: Tab, Backspace, Enter, Esc
Text Terminals send characters (bytes), not key strokes.
Special keys such as Tab, Backspace, Enter and Esc are encoded as control characters.
Control characters are not printable, they display in the terminal as ^ and are intended to have an effect on applications.
Ctrl+I = Tab
Ctrl+J = Newline
Ctrl+M = Enter
Ctrl+[ = Escape
Ctrl+v often meant "verbatim insert", it tells the terminal to not interpret the following character, but insert the following character literally without performing any associated action.
For example:
1, Ctrl+v Ctrl-I will display a tab character,
2, similarly Ctrl+v ENTER will display the escape sequence for the Enter key: ^M.
3, A normal Esc switches to command mode in the vi editor, but CtrlV, Esc will insert the ESC character into the document.
4, Pressing Ctrl+V and then Ctrl+Backspace reveals that the Ctrl+Backspace combination is written as ^H.
操作历史:
Ctrl + r Recall the last command including the specified character(s).
searches the command history as you type.
Equivalent to : vim ~/.bash_history.
Ctrl + p Previous command in history (i.e. walk back through the command history) (Or Up arrow)
Ctrl + n Next command in history (i.e. walk forward through the command history) (Or Down arrow)
Ctrl + o Execute the command found via Ctrl+r
Ctrl + g Escape from history searching mode
!! Repeat last command
!n Repeat from the last command: args n e.g. !:2 for the second argumant.
!n:m Repeat from the last command: args from n to m. e.g. !:2-3 for the second and third.
!n:$ Repeat from the last command: args n to the last argument.
!n:p Print last command starting with n
!string Print the last command beginning with string.
!:q Quote the last command with proper Bash escaping applied.
Tip: enter a line of Bash starting with a # comment, then run !:q on the next line to escape it.
!$ Last argument of previous command.
ALT + . Last argument of previous command.
!* All arguments of previous command.
^abc^def Run previous command, replacing abc with def
程序控制:
Ctrl + C Interrupt/Kill whatever you are running (SIGINT).
(CtrlC almost everywhere in Unix was the "interrupt" key, used to cancel the current program or operation.)
Ctrl + s Stop output to the screen (for long running verbose commands).
Then use PgUp/PgDn for navigation.
Ctrl + q Allow output to the screen (if previously stopped using command above).
Ctrl + D Send an EOF marker, unless disabled by an option, this will close the current shell (EXIT).
Ctrl + Z Send the signal SIGTSTP to the current task, which suspends it.
To return to it later enter fg 'process name' (foreground).
Emacs mode vs Vi Mode
All the above assume that bash is running in the default Emacs setting, if you prefer this can be switched to Vi shortcuts instead.
Set Vi Mode in bash:
$ set -o vi
Set Emacs Mode in bash:
$ set -o emacs
窗口大小改变:
Ctrl + - : 字体和控制终端窗口变小
Ctrl + + : 字体和控制终端窗口变大
参考:
bash keyboard shortcuts - Linux - SS64.com
Why does Ctrl + V not paste in Bash (Linux shell)? - Super User
The Best Keyboard Shortcuts for Bash (aka the Linux and macOS Terminal)