Gru*_*bel 39 bash command-history
不时地将命令直接添加到 Bash 中的历史记录而不实际执行它会很有用。到目前为止,我发现的封闭的东西是#在它前面添加一个并点击返回。有更好的方法吗?
Spi*_*iff 51
history -s 命令
Den*_*son 10
history -s 命令
您甚至可以绑定一个按键来为您执行此操作。您可以在 Bash 提示符下输入:
bind '"\C-q": "\C-a history -s \C-j"'
Run Code Online (Sandbox Code Playgroud)
或将此添加到您的~/.inputrc:
"\C-q": "\C-a history -s \C-j"
Run Code Online (Sandbox Code Playgroud)
然后你可以输入一些东西并按下Ctrl-q它会被添加到历史记录中而不会被执行。如果您的变量包含或 ,则“history”之前的空格会导致history命令本身不会添加到历史记录HISTCONTROL中。可以选择另一个击键而不是“\Cq”。ignorespaceignoreboth
| 归档时间: |
|
| 查看次数: |
9790 次 |
| 最近记录: |