Guake / guake

Drop-down terminal for GNOME
https://guake.github.io
GNU General Public License v2.0
4.41k stars 576 forks source link

VTE Title not always working #203

Closed db4rne closed 11 years ago

db4rne commented 11 years ago

The automatic tab renaming isn't always working, especially not if you use some colours in your hostname. It would be nice if this could be fixed, since the feature is really cool.

pypingou commented 11 years ago

Might be good to explain how to reproduce since you're the first one to report this :)

db4rne commented 11 years ago

sorry, I will try my best:

I'm using Linux Mint 15, and if I open guake it only says "Terminal" as name of the tab. If I login into some ubuntu server via ssh it renames the tab correctly to username@hostname of the server. This problem seems to be related to colours in the user@hostname-string (I'm sorry, I really don't know much about shell-stuff), but not exclusive, since I have the same problem with a Debian 7.1 server.

so, steps to reproduce are: 1) install Linux mint 15 in a VM 2) ssh into your VM 3) check the name of the tab in guake

I don't know much about shell-stuff, but I think the colour-stuff should be in /etc/profile or /etc/bash.bashrc, so I attached both of them to this comment. I hope that will help.

I'm willing to do some more research if you could point out a few directions for me.

It looks like the Mint-Guys are implementing the colour of the promt like this: https://wiki.archlinux.org/index.php/Color_Bash_Prompt#A_well-established_Bash_color_prompt

/etc/bash.bashrc

# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

use_color=false

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.  Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors   ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs}    ]] \
        && type -P dircolors >/dev/null \
        && match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true

if ${use_color} ; then
        # Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
        if type -P dircolors >/dev/null ; then
                if [[ -f ~/.dir_colors ]] ; then
                        eval $(dircolors -b ~/.dir_colors)
                elif [[ -f /etc/DIR_COLORS ]] ; then
                        eval $(dircolors -b /etc/DIR_COLORS)
                fi
        fi

        if [[ ${EUID} == 0 ]] ; then
                PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
        else
                PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
        fi

        alias ls='ls --color=auto'
        alias grep='grep --colour=auto'
else
        if [[ ${EUID} == 0 ]] ; then
                # show root@ when we don't have colors
                PS1='\u@\h \W \$ '
        else
                PS1='\u@\h \w \$ '
        fi
fi

# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term match_lhs

# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
#    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
#    ;;
#*)
#    ;;
#esac

# enable bash completion in interactive shells
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found ]; then
    function command_not_found_handle {
            # check because c-n-f could've been removed in the meantime
                if [ -x /usr/lib/command-not-found ]; then
           /usr/bin/python /usr/lib/command-not-found -- $1
                   return $?
        else
           return 127
        fi
    }
fi

/usr/bin/mint-fortune

/etc/

/etc/profile

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi
ulidtko commented 11 years ago

It's duty of the currently running terminal application (such as bash/zsh/vim/top/...) to request terminal titles. All Guake does is just satisfying (i.e. not ignoring) those requests.

To configure your bash to request user@hostname VTE title on each prompt, add this to your ~/.bashrc (or, if you can, to your distribution's /etc/bash.bashrc — that'd be even better):

case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;\u@\h\a\]$PS1"
    ;;
*)
    ;;
esac
db4rne commented 11 years ago

thanks, and sorry for the wrong bugreport

Senset commented 5 years ago

Hi, I had the same issue, but difference on: if other server hostname contains dots - VTE does not rename a tab or need to create new issue?

mlouielu commented 5 years ago

@Senset Could you run with latest version guake and give us the result of guake --support?

Senset commented 5 years ago

@mlouielu guake --support

$ guake --support Guake Version: 3.6.4 Vte Version: 0.42.5 Vte Runtime Version: 0.42.5 -------------------------------------------------- GTK+ Version: 3.18.9 GDK Backend: GdkX11.X11Display -------------------------------------------------- Desktop Session: xfce -------------------------------------------------- Display: :0.0 RGBA visual: True Composited: True Traceback (most recent call last): File "/usr/local/bin/guake", line 10, in sys.exit(exec_main()) File "/usr/local/lib/python3.5/dist-packages/guake/main.py", line 518, in exec_main if not main(): File "/usr/local/lib/python3.5/dist-packages/guake/main.py", line 372, in main print_support() File "/usr/local/lib/python3.5/dist-packages/guake/support.py", line 103, in print_support get_display() File "/usr/local/lib/python3.5/dist-packages/guake/support.py", line 95, in get_display populate_display(display) File "/usr/local/lib/python3.5/dist-packages/guake/support.py", line 33, in populate_display n_monitors = display.get_n_monitors() AttributeError: 'X11Display' object has no attribute 'get_n_monitors'
ulidtko commented 5 years ago

@Senset please try this quick test:

$ printf '\x1b]0;asdf@qwer.zxcv\a'; sleep 2

Most likely, it's your shell setup (bashrc/bashprofile/zshrc what have you) that fails to process the dots in FQDN correctly. Oh! and make sure you use \H instead of \h in your PS1. man bash /^PROMPTING for more info.

Senset commented 5 years ago

@ulidtko Yeap =( I see "asdf@qwer.zxcv". Sorry, thx