题意:

在已存在的 tmux 会话内部创建一个新的 tmux 会话

问题背景:

I'm writing a shell script that creates / attaches or switches to a given session, depending on whether one is inside tmux and the session exists.

我正在编写一个 shell 脚本,该脚本会根据当前是否处于 tmux 会话中以及目标会话是否存在,来创建/附加或切换到指定的会话。

I've got everything working great except for the case requiring the creation of a new tmux session from within a tmux session.

除了需要在已有的 tmux 会话内部创建新 tmux 会话的场景外,其他所有功能均已完美运行。

When my script executes tmux new-session -s name, I get the following output:

当我的脚本执行 tmux new-session -s name 时,会出现以下输出/提示:

sessions should be nested with care, unset $TMUX to force

I don't actually want to nest sessions, my goal is to create another separate session and switch to it from within a tmux session.

我并不想要嵌套会话,我的目标是‌在现有 tmux 会话中创建另一个独立的新会话,并切换至该新会话‌。

Is this possible?

这可能实现吗?

问题解决:

The quickest way (assuming you use ctrl-b as your command prefix) is:

最快的方法(假设你使用 Ctrl-b 作为命令前缀键)是:

ctrl-b :new

To create a new session, then

要创建一个新会话,可执行以下操作步骤:

ctrl-b s

to interactively select and attach to the session.

以交互方式选择并附加到目标会话

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐