Skip to content

Instantly share code, notes, and snippets.

@geeksam
Last active November 27, 2018 18:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geeksam/9755275 to your computer and use it in GitHub Desktop.
Save geeksam/9755275 to your computer and use it in GitHub Desktop.
Short list of usernames, for wemux session only
I mostly work in a wemux session so that my coworkers can SSH in and join me on
short notice, and have configured my tmux status bar to show the usernames of
everyone who's logged in. However, I also sometimes have tmux sessions open with
personal projects, and don't need to see usernames in *those* sessions. Also,
some people have really long usernames, so I want to assign them nicknames so
the entire list doesn't get truncated.
set -g status-right " #[fg=green]#(wemux_user_list) #[fg=yellow]%R"
#!/usr/bin/env ruby
NICKNAMES = {
'samlivingston-gray' => 'samlg',
}
def in_wemux_session?
tmux_session = `tmux display-message -p '#S'`.strip
tmux_session == 'wemux'
end
def short_user_list
list = `wemux status_users`.strip.split(/\s+/)
nicknames = list.map {|name| NICKNAMES[name] || name[0...6] }
nicknames.join(', ')
end
puts short_user_list if in_wemux_session?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment