zsh 检测它的 tmux window 或 pane

zsh detect if its tmux window or pane

我想检测它的 tmux 窗格或 window。如果它的 window archey 应该 运行,如果它不是另一个面板。

我试过跟随,但这显然行不通。

# Only run if archey is actually installed
if which archey &> /dev/null
    then
        if [[ "$ARCHEY_STARTED" != "true" ]]
            then
                export ARCHEY_STARTED=true
                archey
        fi
else
    print "zsh archey plugin: archey not found. Please install archey before using this plugin: brew install archey"
fi

我是在尝试只在新的 windows 中使用苹果徽标,而不是在窗格中。你同意在窗格中它变得烦人:

我想实现这个:

使用@chepners 的建议,您可以以此为起点

# Only run if archey is actually installed
if which archey &> /dev/null
then
    if [[ "$ARCHEY_STARTED" != "true" -a "1x" == "$(tmux list-panes -F'#{window_panes}' | head -n 1)x" ]]
        then
            export ARCHEY_STARTED=true
            archey
    fi
else
    print "zsh archey plugin: archey not found. Please install archey before using this plugin: brew install archey"
fi

我通过 head 管道输出 tmux,因为给定的命令将为当前 window 的每个窗格输出 pane-count。