0

I write a simple shell script to help tmux show all the session in the status bar, however, the tmux's status bar always show the same thing in the different clients when they are all attached. My script is as follows.

#!/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 Answers1

1

TL;DR: No.

Tmux sessions are designed to show exactly the same thing for all connected users. If a user is connecting on a small terminal, everyone's view will be squashed to only show the small terminal size. There is no way around that (unless you're viewing different windows in the same session), and there is no way to show different content to different users when viewing the same window.

jeremysprofile
  • 10,028
  • 4
  • 33
  • 53
  • very sad to hear this. But is there a way similar to Github's plugin [tmux-prefix-highlight](tmux-prefix-highlight) that can show different contents in not only different clients but also different iterm2's window? – hei_threebody Mar 25 '19 at 18:45
  • I know that tmux-prefix-highlight uses tmux variable which is `pane_in_mode`, any other variables can be possibly used? – hei_threebody Mar 25 '19 at 18:48