有没有办法让Tux都在附加了所有客户端的情况下使状态栏显示不同的内容?

时间:2019-03-25 17:16:29

标签: shell tmux

我写了一个简单的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??

1 个答案:

答案 0 :(得分:0)

TL; DR:否。

Tmux会话旨在为所有连接的用户准确显示 相同的内容。如果用户正在小型终端上进行连接,则所有人的视图将被压缩为仅显示the small terminal size。无法解决此问题(除非您在同一会话中查看不同的窗口),并且在查看同一窗口时也无法向不同的用户显示不同的内容。