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

时间:2013-05-09 02:22:14

标签: tmux

我写了this thing,每当在正在运行的会话中创建一个新窗口时,我想要一个Python virtualenv激活脚本。

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

1 个答案:

答案 0 :(得分:4)

我做出以下假设:

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

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

    if [[ $TMUX ]]; then
        # code here
    fi
    

    此代码仅适用于现有tmux会话中的新shell。

相关问题