This commit is contained in:
parent
089efa795e
commit
98935dc9ba
1 changed files with 15 additions and 14 deletions
29
sh/tmux.sh
29
sh/tmux.sh
|
@ -54,28 +54,29 @@ rwx_tmux_server() {
|
|||
--fields \"1\"
|
||||
}
|
||||
rwx_tmux_servers() {
|
||||
local active=\"\$(rwx_tmux_server)\"
|
||||
local name path text
|
||||
local paths=\"\$(lsof -U |
|
||||
awk \"/^tmux:.*\\(LISTEN\\)\$/ {print \\\$9}\")\"
|
||||
while IFS= read -r path; do
|
||||
name=\"\$(basename \"\${path}\")\"
|
||||
text=\"\${text}\\
|
||||
local active name root sockets text
|
||||
active=\"\$(rwx_tmux_server)\"
|
||||
root=\"/tmp/tmux-\$(id -u)\"
|
||||
sockets=\"\$(find \"\${root}\" -type s -printf \"%P\\n\")\"
|
||||
while IFS= read -r name; do
|
||||
if tmux -L \"\${name}\" list-sessions; then
|
||||
text=\"\${text}\\
|
||||
#[fg=default]\\
|
||||
#[bg=default] \\
|
||||
\"
|
||||
if [ \"\${active}\" = \"\${name}\" ]; then
|
||||
text=\"\${text}#[fg=green]\"
|
||||
else
|
||||
text=\"\${text}#[fg=yellow]\"
|
||||
fi
|
||||
text=\"\${text}\\
|
||||
if [ \"\${name}\" = \"\${active}\" ]; then
|
||||
text=\"\${text}#[fg=green]\"
|
||||
else
|
||||
text=\"\${text}#[fg=yellow]\"
|
||||
fi
|
||||
text=\"\${text}\\
|
||||
#[bg=##181818] \\
|
||||
#[bg=##282828]\${name}\\
|
||||
#[bg=##181818] \\
|
||||
\"
|
||||
fi
|
||||
done <<EOF
|
||||
\${paths}
|
||||
\${sockets}
|
||||
EOF
|
||||
echo \"\${text}\"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue