bash - Bash 历史 - 多行字符串导致多行历史
问题描述
我更喜欢将所有 shell 命令放在一行中,所以~/.bash_history
我确保在.cmdhist
shopt -s cmdhist
~/.bashrc
这可以正常工作:
$ for x in 1 2; do
> echo "$x"
> done
1
2
$ history -a
$ tail -n2 ~/.bash_history
for x in 1 2; do echo "$x"; done
history -a
但是,当输入多行字符串时,它们似乎总是被添加到历史记录中的多行:
$ echo "3
> 4"
3
4
$ echo '5
> 6'
5
6
$ history -a
$ tail -n5 ~/.bash_history
echo "3
4"
echo '5
6'
history -a
这往往会弄乱解析~/.bash_history
文件和CTRL+R搜索的脚本(例如:搜索6
find6'
而不是完整的命令)
有没有办法调整这种行为?它是按预期工作还是一个错误?
重击版本:GNU bash v5.0.17(1)-release
解决方案
推荐阅读
- angular - Angular 6 Keyup 自动货币
- service - 准备就绪-在 Pod 启动时探测另一个服务
- python - 有没有办法将 docx 中的内联形状保存为图像文件?
- javascript - 如何将来自axios post的数据存储在localstorage中
- r - 将存储在列表中的数据框列中的向量传递给 glm
- sql - 如何在现有位置插入新行之前更新唯一表行号
- reactjs - React TypeError:无法读取 null 的属性“propName”
- c++ - 给定基类方法的编译时覆盖
- javascript - 访问回调函数范围之外的变量?
- vue.js - 如何使用 vuetify@2.0.0-beta7