脚本完成时防止 tmux 退出
Prevent tmux from exiting when script finishes
我想防止 tmux 在脚本完成时自动退出。例如,我有一个类似这样的命令(如下),它会 运行 一个应用程序的服务器,但有时它会意外退出并出现错误。发生这种情况时,我无法检查代码、命令有什么问题。
tmux new-session -d -s "visited" 'bash -ic "visited --server"';
下面是我想要执行的简化命令。
tmux new-session -d -s "pwd" 'bash -c pwd' # but actually I need to load .bashrc
tmux a -t pwd # this should attach to the shell, but in my environment this does show "can't find session pwd" since the shell is already exited
我读了一个 github issue 并尝试将 set exit-empty off
添加到 ~/.tmux.conf 并重新启动服务器 tmux kill-server
并重新尝试以上,但似乎不起作用。
只需让 tmux 创建一个普通会话并注入击键:
tmux new-session -d -s pwd
tmux send-keys pwd C-m
tmux a -t pwd
我想防止 tmux 在脚本完成时自动退出。例如,我有一个类似这样的命令(如下),它会 运行 一个应用程序的服务器,但有时它会意外退出并出现错误。发生这种情况时,我无法检查代码、命令有什么问题。
tmux new-session -d -s "visited" 'bash -ic "visited --server"';
下面是我想要执行的简化命令。
tmux new-session -d -s "pwd" 'bash -c pwd' # but actually I need to load .bashrc
tmux a -t pwd # this should attach to the shell, but in my environment this does show "can't find session pwd" since the shell is already exited
我读了一个 github issue 并尝试将 set exit-empty off
添加到 ~/.tmux.conf 并重新启动服务器 tmux kill-server
并重新尝试以上,但似乎不起作用。
只需让 tmux 创建一个普通会话并注入击键:
tmux new-session -d -s pwd
tmux send-keys pwd C-m
tmux a -t pwd