Last active
November 27, 2018 18:55
-
-
Save geeksam/9755275 to your computer and use it in GitHub Desktop.
Short list of usernames, for wemux session only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -g status-right " #[fg=green]#(wemux_user_list) #[fg=yellow]%R" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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