Muh*_*tih 3 bash tmux shell-script
我想写一个 bash 脚本,它将:
我试过这个:
tmux new -d -s my_session '$SHELL -c " sleep 1; echo please dont exit after echo; sleep 1;"'
tmux attach -t my_session
Run Code Online (Sandbox Code Playgroud)
但是这在脚本完成执行后退出。如何让会话保持活动状态,以便我可以附加和执行更多脚本?
您可以执行以下操作之一:
在命令后运行 shell: tmux new -dsmy_session 'mycommand; exec $SHELL'
让 tmux 启动一个 shell,然后输入命令send-keys:tmux new -dsmy_session \; send mycommand Enter
您也可以设置该remain-on-exit选项,但在使用命令创建会话时执行此操作很棘手,因为该命令可能会在您设法设置它之前退出。