【问题标题】:Prevent tmux from exiting when script finishes脚本完成时防止 tmux 退出
【发布时间】:2021-03-16 04:20:37
【问题描述】:

我想防止 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 并重新尝试了上述方法,但似乎它不起作用。

【问题讨论】:

  • bash -c command 启动一个 Bash 实例,运行 command,然后退出。

标签: shell command-line tmux


【解决方案1】:

只需让 tmux 创建一个普通会话并注入击键:

tmux new-session -d -s pwd
tmux send-keys pwd C-m
tmux a -t pwd

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-02
    • 1970-01-01
    • 1970-01-01
    • 2011-01-07
    • 2016-07-27
    • 1970-01-01
    相关资源
    最近更新 更多