【问题标题】:Is there a way for tux to make status bar show different contents in different clients when they are all attached?tux 有没有办法让状态栏在所有附加的客户端中显示不同的内容?
【发布时间】:2019-03-25 17:16:29
【问题描述】:

我编写了一个简单的 shell 脚本来帮助 tmux 在状态栏中显示所有会话,但是,当所有客户端都连接时,tmux 的状态栏总是在不同的客户端中显示相同的内容。 我的脚本如下。

#!/usr/bin/env bash

session=`tmux ls | cut -d " " -f 1 | tr -d ":" | tr "\\n" " "`
# attached_count=`tmux ls | grep -n \(attached\) | cut -d ":" -f 1`
active_session=`tmux display-message -p '#S'`

# session_start="#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack]"
session_start="#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack]"
# session_end="#[fg=black,bg=brightblack,nobold,noitalics,nounderscore]#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]"
session_end="#[fg=black,bg=brightblack,nobold,noitalics,nounderscore]"

session_active_start="#[fg=cyan,bg=black,nobold,noitalics,nounderscore]#[fg=black,bg=cyan]"
session_active_end="#[fg=black,bg=cyan,nobold,noitalics,nounderscore]"

session_str=""
count=1
for i in $session
do
    # if [[ $count -eq $attached_count ]]; then
    if [[ $i == $active_session ]]; then
        session_str="${session_str}${session_active_start}${i}${session_active_end}"
    else
        session_str="${session_str}${session_start}${i}${session_end}"
    fi

    count=$((count+1))
    # break
    # echo "${i}"
done

session_str=`echo ${session_str} | tr -d "\n"`
printf "${session_str}"
```bash


It will output a long string content all my session name and make the attached one in other colors

"#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack]besiii#[fg=black,bg=brightblack,nobold,noitalics,nounderscore]#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack]conf#[fg=black,bg=brightblack,nobold,noitalics,nounderscore]#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack]default#[fg=black,bg=brightblack,nobold,noitalics,nounderscore]#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack]lang#[fg=black,bg=brightblack,nobold,noitalics,nounderscore]#[fg=cyan,bg=black,nobold,noitalics,nounderscore]#[fg=black,bg=cyan]vert#[fg=black,bg=cyan,nobold,noitalics,nounderscore]"

However, all my iterm windows which attach tmux's client will show the same status bar.
Is there a way to make tmux show different contents in different attached clients??

【问题讨论】:

    标签: shell tmux


    【解决方案1】:

    TL;DR:没有。

    Tmux 会话旨在为所有连接的用户显示完全相同的内容。如果用户在一个小终端上连接,每个人的视图将被压缩,只显示the smallterminal size。没有办法解决这个问题(除非您在同一会话中查看不同的窗口),并且在查看同一窗口时无法向不同的用户显示不同的内容。

    【讨论】:

    • 听到这个消息非常难过。但是有没有类似Github的插件[tmux-prefix-highlight](tmux-prefix-highlight)的方式,不仅可以在不同的客户端,也可以在不同的iterm2的窗口中显示不同的内容?
    • 我知道 tmux-prefix-highlight 使用了 tmux 变量 pane_in_mode,还有其他变量可以使用吗?
    猜你喜欢
    • 1970-01-01
    • 2019-08-16
    • 1970-01-01
    • 2023-02-14
    • 2016-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多