toggle-utf8 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh -e
  2. #
  3. # toggle-utf8
  4. # Copyright (C) 2013-2014 Dustin Kirkland
  5. #
  6. # Authors: Dustin Kirkland <kirkland@byobu.org>
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, version 3 of the License.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. PKG="byobu"
  20. [ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc"
  21. [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX
  22. . "${BYOBU_PREFIX}/lib/${PKG}/include/common"
  23. [ -r "$BYOBU_CONFIG_DIR/statusrc" ] && . "$BYOBU_CONFIG_DIR/statusrc"
  24. if [ "$BYOBU_CHARMAP" = "UTF-8" ]; then
  25. if grep -qs "^BYOBU_CHARMAP=" $BYOBU_CONFIG_DIR/statusrc 2>/dev/null; then
  26. sed -i -e "s/^BYOBU_CHARMAP=.*/BYOBU_CHARMAP=x/" $BYOBU_CONFIG_DIR/statusrc
  27. else
  28. echo "BYOBU_CHARMAP=x" >> $BYOBU_CONFIG_DIR/statusrc
  29. fi
  30. export BYOBU_CHARMAP=x
  31. else
  32. if grep -qs "^BYOBU_CHARMAP=" $BYOBU_CONFIG_DIR/statusrc 2>/dev/null; then
  33. sed -i -e "s/^BYOBU_CHARMAP=.*/BYOBU_CHARMAP=UTF-8/" $BYOBU_CONFIG_DIR/statusrc
  34. else
  35. echo "BYOBU_CHARMAP=UTF-8" >> $BYOBU_CONFIG_DIR/statusrc
  36. fi
  37. export BYOBU_CHARMAP=UTF-8
  38. fi
  39. if [ -n "$TMUX" ]; then
  40. RC_FILE=$(echo "$SHELL" | $BYOBU_SED "s:.*/::")
  41. tmux send-keys " export BYOBU_CHARMAP=$BYOBU_CHARMAP ; . ~/.${RC_FILE}rc" \; send-keys Enter
  42. fi
  43. # vi: syntax=sh ts=4 noexpandtab