cycle-status 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. #
  3. # cycle-status: cycle the status bar through multiple configurations
  4. #
  5. # Copyright (C) 2011-2014 Dustin Kirkland
  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. # Find line number of the enabled tmux_right
  21. current=$(grep -n "^tmux_right=" "$BYOBU_CONFIG_DIR/status" | awk -F: '{print $1}' | tail -n1)
  22. # Find next line number to enable
  23. all=$(grep -n "tmux_right=" "$BYOBU_CONFIG_DIR/status" | awk -F: '{print $1}')
  24. next=
  25. for i in $all $all; do
  26. if [ "$next" = "flagged" ]; then
  27. next="$i"
  28. break
  29. elif [ "$i" = "$current" ]; then
  30. next="flagged"
  31. fi
  32. done
  33. # Disable all
  34. sed -i -e "s/^tmux_right=/#tmux_right=/" "$BYOBU_CONFIG_DIR/status"
  35. # Enable the next one
  36. sed -i -e "${next}s/^#tmux_right=/tmux_right=/" "$BYOBU_CONFIG_DIR/status"