【问题标题】:zsh detect if its tmux window or panezsh 检测它的 tmux 窗口或窗格
【发布时间】:2017-01-14 18:44:13
【问题描述】:

我想检测它的 tmux 窗格还是窗口。如果它的 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

我是否正在尝试仅在新窗口而不是窗格中使用苹果徽标。您同意在窗格中它变得烦人:

我想实现这个:

【问题讨论】:

  • 程序总是在窗格中运行,一个窗口只是一个或多个窗格的集合。采用格式的tmux 命令有一个变量window_panes,它扩展为窗口中的窗格数。你也许可以用它做点什么,只有在 count == 1 时才运行命令。
  • @chepner $TMUX 没有返回任何可用的东西,你知道任何返回窗格或窗口信息的环境变量吗?

标签: zsh tmux


【解决方案1】:

使用@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

我将tmuxs 的输出通过head 管道化,因为给定的命令将输出当前窗口的每个窗格的窗格计数。

【讨论】:

    猜你喜欢
    • 2012-03-24
    • 2011-07-23
    • 1970-01-01
    • 1970-01-01
    • 2013-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多