session 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/sh -e
  2. #
  3. # session: tmux session name
  4. #
  5. # Copyright (C) 2013-2014 Dustin Kirkland <kirkland@byobu.org>
  6. #
  7. # Authors: Dustin Kirkland <kirkland@byobu.org>
  8. #
  9. # This program is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, version 3 of the License.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. __session_detail() {
  21. tmux list-sessions
  22. }
  23. __session() {
  24. # Note: This will only work in byobu-tmux
  25. case "$BYOBU_BACKEND" in
  26. tmux)
  27. local count=$(tmux list-sessions 2>/dev/null | grep -v "^_" | wc -l)
  28. if [ $count -gt 1 ]; then
  29. color u W k; printf "${ICON_SESSION}#S"; color --
  30. else
  31. echo
  32. fi
  33. ;;
  34. screen)
  35. local count=$(screen -ls | grep "^\s\+.*)$" | wc -l)
  36. if [ $count -gt 1 ]; then
  37. color u W k; printf "${ICON_SESSION}%S"; color --
  38. else
  39. echo
  40. fi
  41. ;;
  42. esac
  43. }
  44. # vi: syntax=sh ts=4 noexpandtab