为 tmux 中的每个新窗口运行一个命令

mqs*_*soh 4 tmux

我写了这个东西,我想在运行会话中创建一个新窗口时提供一个 Python virtualenv 激活脚本。

是否可以?default-command 选项与 shell 相关,而不是附加命令。

che*_*ner 5

我做出以下假设:

  1. 您正在使用bash
  2. 您的.bashrc文件是启动 shell 的每个新窗口的源代码
  3. 您只想在运行 shell 的窗口中启动 virtualenv

将您要运行的代码添加到您的.bashrc

if [[ $TMUX ]]; then
    # code here
fi
Run Code Online (Sandbox Code Playgroud)

此代码仅针对现有会话中的新 shell 运行tmux