我最近发现,在终端中,Ctrl-i 与 Tab 相同(这在我的手机上非常有用,因为手机上没有箭头键也没有 Tab 键)。
在普通终端上按向上键可以浏览历史记录。
还有其他方法可以回忆起最后一条命令吗?
答案1
Ctrl+p在命令历史记录中向后移动
Ctrl+n在命令历史记录中向前移动
(我读到过一些文章说它是用 Alt 键,但对我来说 Ctrl 键才有用)
答案2
您可以,如果它有助于输入!-1
您输入的最后一个命令。
如果你想要倒数第二个,那么!-2
输入人类历史说:
事件指示器
An event designator is a reference to a command line entry in the history list.
Unless the reference is absolute, events are relative to the current position in
the history list.
! Start a history substitution, except when followed by a blank,
newline, = or (.
!n Refer to command line n.
!-n Refer to the current command minus n.
!! Refer to the previous command. This is a synonym for `!-1'.
!string
Refer to the most recent command preceding the current position
in the history list starting with string.
!?string[?]
Refer to the most recent command preceding the current postition
in the history list containing string. The trailing ? may be
omitted if string is followed immediately by a newline.
^string1^string2^
Quick substitution. Repeat the last command, replacing string1
with string2. Equivalent to ``!!:s/string1/string2/'' (see Mod‐
ifiers below).
!# The entire command line typed so far.
您还可以使用CTRL+P一次返回一个历史命令。
使用CTRL+N一次前进一个历史命令。