Last active
March 9, 2017 12:52
-
-
Save dohzya/6ad2a6a6765f43ab9c52 to your computer and use it in GitHub Desktop.
List tmux sessions (for every sockets)
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 | |
| sockets = %x(ps ax -o args=).lines.grep(/tmux.*-L/).map{|l| l.chomp.match(/-L +([^ ]+)/)[1] }.uniq | |
| servers = [['default', nil]] + sockets.sort.map{|s| [s, s] } | |
| res = [] | |
| servers.each do |srv, sock| | |
| res << "#{srv}:" | |
| arg = sock ? "-L #{sock}" : "" | |
| %x(tmux #{arg} ls 2> /dev/null).each_line{|l| res << "- #{l.chomp}" } | |
| res << "" | |
| end | |
| puts res.join("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment