~/.bashrc 中添加了函数 rhist,其中的 $result 是由历史命令查询工具 rhist 返回的。
现在是 $result 添加到了历史记录中了,但要手动用上方向键调出来。我想的是把 $result 自动填充到命令提示符上去,等待编辑或者执行。
rhist() {
local result=$(command rhist "$@")
[ -n "$result" ] && echo "$result" && echo "$result" >> ~/.bash_history && history -r
}现在是:
[root@VM-4-8-centos ~]# rhist
结果内容
[root@VM-4-8-centos ~]#
期望的结果是:
[root@VM-4-8-centos ~]# rhist
[root@VM-4-8-centos ~]# 结果内容
AI工具查过,没有得到想要的结果