如果我有一个类似的进程,rails c
或者guard
我退出命令退出,那么tmux窗口也会退出.
当我只想重新启动例如轨道控制台时,这不太实用.
我可以在tmux中阻止此行为吗?
您可以设置remain-on-exit
窗口选项以防止tmux在运行它的进程结束时关闭窗口(窗格).
setw remain-on-exit on
Run Code Online (Sandbox Code Playgroud)
会话选项set-remain-on-exit
也可用; 使用它,您可以安排会话的所有窗口/窗格自动remain-on-exit
打开.
一个后remain-on-exit
面板的过程结束后,面板会显示消息"窗格死了",直到它与命令关闭kill-pane
(或kill-window
),或一个新的命令与在那里开始respawn-pane
(或respawn-window
).
respawn-pane 'rails c' # respawn with a specific command
respawn-pane # respawn whatever the previous command
Run Code Online (Sandbox Code Playgroud)
If you are not overly concerned about cleanly exiting a pane’s existing process, then you can even restart a pane without first exiting its current process like this:
respawn-pane -k # kill current process (if any) and respawn the previous command
Run Code Online (Sandbox Code Playgroud)