[ Jeffery To ]

* usr/bin/byobu.in, usr/share/byobu/profiles/tmux:
  - use screen-256color if possible, for both screen and tmux
This commit is contained in:
Jeffery To 2016-08-05 21:08:08 +08:00
commit dff5ec6658
3 changed files with 37 additions and 14 deletions

4
debian/changelog vendored
View file

@ -1,6 +1,8 @@
byobu (5.111) unreleased; urgency=medium byobu (5.111) unreleased; urgency=medium
* UNRELEASED [ Jeffery To ]
* usr/bin/byobu.in, usr/share/byobu/profiles/tmux:
- use screen-256color if possible, for both screen and tmux
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 29 Jul 2016 12:29:07 -0500 -- Dustin Kirkland <kirkland@ubuntu.com> Fri, 29 Jul 2016 12:29:07 -0500

View file

@ -109,13 +109,36 @@ if [ -S "$SSH_AUTH_SOCK" ] && [ ! -h "$SSH_AUTH_SOCK" ]; then
export SSH_AUTH_SOCK="$BYOBU_CONFIG_DIR/.ssh-agent" export SSH_AUTH_SOCK="$BYOBU_CONFIG_DIR/.ssh-agent"
fi fi
# Terminfo we will use
BYOBU_TERM="screen"
# Color terminfo to use, if possible
BYOBU_COLOR_TERM="screen-256color"
# Check if our terminfo supports 256 colors
CAN_SHOW_COLORS=
if $BYOBU_TEST tput >/dev/null 2>&1; then
if [ "$(tput colors 2>/dev/null || echo 0)" = "256" ]; then
CAN_SHOW_COLORS=1
fi
fi
# Check if the color terminfo is available
HAS_COLOR_TERM=
if $BYOBU_TEST infocmp >/dev/null 2>&1; then
if infocmp "$BYOBU_COLOR_TERM" >/dev/null 2>&1; then
HAS_COLOR_TERM=1
fi
fi
case $BYOBU_BACKEND in case $BYOBU_BACKEND in
tmux) tmux)
# Use 256 colors if possible # Use 256 colors if possible
if $BYOBU_TEST tput >/dev/null; then if [ -n "$CAN_SHOW_COLORS" ] || [ "$COLORTERM" = "gnome-terminal" ] || [ "$TERM" = "xterm" ] || [ "$TERM" = "xterm-256color" ] || [ "$TERM" = "screen" ]; then
if [ "$(tput colors 2>/dev/null || echo 0)" = "256" ] || [ "$COLORTERM" = "gnome-terminal" ] || [ "$TERM" = "xterm" ] || [ "$TERM" = "xterm-256color" ] || [ "$TERM" = "screen" ]; then [ -z "$SCREEN_TERM" ] && SCREEN_TERM="-2"
[ -z "$SCREEN_TERM" ] && SCREEN_TERM="-2" fi
fi if [ -n "$SCREEN_TERM" -a -n "$HAS_COLOR_TERM" ]; then
BYOBU_TERM="$BYOBU_COLOR_TERM"
fi fi
BYOBU_PROFILE="-f $BYOBU_PREFIX/share/$PKG/profiles/tmuxrc" BYOBU_PROFILE="-f $BYOBU_PREFIX/share/$PKG/profiles/tmuxrc"
# Set default window, unless user has overriden # Set default window, unless user has overriden
@ -150,12 +173,11 @@ case $BYOBU_BACKEND in
export BYOBU_WINDOWS export BYOBU_WINDOWS
# Launch shell, unless the user has default windows set to launch # Launch shell, unless the user has default windows set to launch
uncommented_lines < "$BYOBU_WINDOWS" && DEFAULT_WINDOW= || DEFAULT_WINDOW="${BYOBU_PREFIX}/bin/byobu-shell" uncommented_lines < "$BYOBU_WINDOWS" && DEFAULT_WINDOW= || DEFAULT_WINDOW="${BYOBU_PREFIX}/bin/byobu-shell"
# Check if our terminfo supports 256 colors # Use 256 colors if possible
if $BYOBU_TEST tput >/dev/null; then if [ -n "$CAN_SHOW_COLORS" -a -n "$HAS_COLOR_TERM" ]; then
if [ "$(tput colors 2>/dev/null || echo 0)" = "256" ]; then BYOBU_TERM="$BYOBU_COLOR_TERM"
SCREEN_TERM="-T screen-256color"
fi
fi fi
SCREEN_TERM="-T $BYOBU_TERM"
# Some users want to maintain separate configurations # Some users want to maintain separate configurations
# if they use both GNU Screen and byobu on the same system # if they use both GNU Screen and byobu on the same system
if [ -r "$BYOBU_CONFIG_DIR/.screenrc" ]; then if [ -r "$BYOBU_CONFIG_DIR/.screenrc" ]; then
@ -176,6 +198,8 @@ case $BYOBU_BACKEND in
;; ;;
esac esac
export BYOBU_TERM
# Save session info # Save session info
[ -n "$DBUS_SESSION_BUS_ADDRESS" ] && printf "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS\n" > "$BYOBU_RUN_DIR/sockets" [ -n "$DBUS_SESSION_BUS_ADDRESS" ] && printf "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS\n" > "$BYOBU_RUN_DIR/sockets"
[ -n "$SESSION_MANAGER" ] && printf "SESSION_MANAGER=$SESSION_MANAGER\n" >> "$BYOBU_RUN_DIR/sockets" [ -n "$SESSION_MANAGER" ] && printf "SESSION_MANAGER=$SESSION_MANAGER\n" >> "$BYOBU_RUN_DIR/sockets"

View file

@ -68,10 +68,7 @@ set-window-option -g automatic-rename on
set-window-option -g aggressive-resize on set-window-option -g aggressive-resize on
set-window-option -g monitor-activity on set-window-option -g monitor-activity on
# Cannot use: set -g default-terminal "$BYOBU_TERM"
# - screen-bce, screen-256color-bce: tmux does not support bce
# - screen-256color: vim broken without -bce
set -g default-terminal "screen"
# The following helps with Shift-PageUp/Shift-PageDown # The following helps with Shift-PageUp/Shift-PageDown
set -g terminal-overrides 'xterm*:smcup@:rmcup@' set -g terminal-overrides 'xterm*:smcup@:rmcup@'