gpt4 book ai didi

tmux send-keys 命令在屏幕上出现两次

转载 作者:行者123 更新时间:2023-12-04 13:48:35 24 4
gpt4 key购买 nike

我是 tmux 的新手,当我尝试时发现这种行为非常奇怪。

我写了一个非常简单的脚本

tmux new-session -s "test" -d
tmux send-keys -t test hello Enter
tmux attach -t "test"

当我运行它时,shell 显示以下内容
hello
eric:bin$ hello

我只希望“hello”命令在提示符内显示一次,但“hello”命令将显示两次:一个在提示符外,一个在提示符内

有谁知道原因?

最佳答案

我不认为这是 tmux问题。发生的事情是tmux在 shell 完成加载之前将 key 发送到窗口。

您可以通过执行以下操作来查看该现象:

$ sleep 3
hello
$ hello
bash: hello: command not found

sleep 3正在运行时,您可以键入“hello”+ Enter 并且只有在该程序完成运行时, bash解释输入。

您可以通过加快 shell 加载速度来解决此问题。

关于tmux send-keys 命令在屏幕上出现两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30413047/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com