From dff5ec66585b574b1e31f713fe23de4e95976154 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Fri, 5 Aug 2016 21:08:08 +0800 Subject: [PATCH] [ Jeffery To ] * usr/bin/byobu.in, usr/share/byobu/profiles/tmux: - use screen-256color if possible, for both screen and tmux --- debian/changelog | 4 +++- usr/bin/byobu.in | 42 +++++++++++++++++++++++++++-------- usr/share/byobu/profiles/tmux | 5 +---- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/debian/changelog b/debian/changelog index 7011d40f..aa0a4ac8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ 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 Fri, 29 Jul 2016 12:29:07 -0500 diff --git a/usr/bin/byobu.in b/usr/bin/byobu.in index 7b8d485d..9933b4d3 100755 --- a/usr/bin/byobu.in +++ b/usr/bin/byobu.in @@ -109,13 +109,36 @@ if [ -S "$SSH_AUTH_SOCK" ] && [ ! -h "$SSH_AUTH_SOCK" ]; then export SSH_AUTH_SOCK="$BYOBU_CONFIG_DIR/.ssh-agent" 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 tmux) # Use 256 colors if possible - if $BYOBU_TEST tput >/dev/null; 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" - fi + if [ -n "$CAN_SHOW_COLORS" ] || [ "$COLORTERM" = "gnome-terminal" ] || [ "$TERM" = "xterm" ] || [ "$TERM" = "xterm-256color" ] || [ "$TERM" = "screen" ]; then + [ -z "$SCREEN_TERM" ] && SCREEN_TERM="-2" + fi + if [ -n "$SCREEN_TERM" -a -n "$HAS_COLOR_TERM" ]; then + BYOBU_TERM="$BYOBU_COLOR_TERM" fi BYOBU_PROFILE="-f $BYOBU_PREFIX/share/$PKG/profiles/tmuxrc" # Set default window, unless user has overriden @@ -150,12 +173,11 @@ case $BYOBU_BACKEND in export BYOBU_WINDOWS # Launch shell, unless the user has default windows set to launch uncommented_lines < "$BYOBU_WINDOWS" && DEFAULT_WINDOW= || DEFAULT_WINDOW="${BYOBU_PREFIX}/bin/byobu-shell" - # Check if our terminfo supports 256 colors - if $BYOBU_TEST tput >/dev/null; then - if [ "$(tput colors 2>/dev/null || echo 0)" = "256" ]; then - SCREEN_TERM="-T screen-256color" - fi + # Use 256 colors if possible + if [ -n "$CAN_SHOW_COLORS" -a -n "$HAS_COLOR_TERM" ]; then + BYOBU_TERM="$BYOBU_COLOR_TERM" fi + SCREEN_TERM="-T $BYOBU_TERM" # Some users want to maintain separate configurations # if they use both GNU Screen and byobu on the same system if [ -r "$BYOBU_CONFIG_DIR/.screenrc" ]; then @@ -176,6 +198,8 @@ case $BYOBU_BACKEND in ;; esac +export BYOBU_TERM + # Save session info [ -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" diff --git a/usr/share/byobu/profiles/tmux b/usr/share/byobu/profiles/tmux index c63558b7..2e54bcc9 100644 --- a/usr/share/byobu/profiles/tmux +++ b/usr/share/byobu/profiles/tmux @@ -68,10 +68,7 @@ set-window-option -g automatic-rename on set-window-option -g aggressive-resize on set-window-option -g monitor-activity on -# Cannot use: -# - screen-bce, screen-256color-bce: tmux does not support bce -# - screen-256color: vim broken without -bce -set -g default-terminal "screen" +set -g default-terminal "$BYOBU_TERM" # The following helps with Shift-PageUp/Shift-PageDown set -g terminal-overrides 'xterm*:smcup@:rmcup@'