类似于PowerShell,如何查看Bash历史记录列表?

4

使用PSReadLine 2.2.0 beta4版本

Set-PSReadLineOption -PredictionSource History

Set-PSReadLineOption -PredictionViewStyle ListView

Powershell可以像这样展示历史记录:

enter image description here

在Linux系统中,Bash或其他shell是否有此功能?


3
PowerShell 是一个 Linux Shell。如果它具备你需要的功能,为什么还需要另一个 Shell 呢? - Doug Maurer
你懂我了。但是我需要的是具备这个功能的Bash。PowerShell很好,但它太像Windows了。 - Gary Allen
1个回答

0

你可以使用 history 命令查看之前输入的命令。 如果你想要筛选,可以使用 grep 命令,例如

history | grep git

你将会得到例如:

  207  git push origin init-repo
  226  git status
  227  git add war/src/main/java/com/xxx/Application.java
  228  git status
  229  git fetch
  230  git checkout init-repo
  231  git stash
  232  git stash pop
  233  git add pom.xml
  234  git status
  235  git add *
  236  git add all
  237  git add-all
  238  git --help
  239  git add --all
  240  git stash
  241  git stash pop
  242  git add --all
  243  git pull
  502  history | grep git
[admin@host]$ 


3
如何以这样的方式使用它,使其能够“随键入而运行”,并提供一个可选择的列表,就像屏幕截图中所示的那样? - J_D

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接