Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 407473 - >=app-portage/eix-0.24.0 doesn't clear status on exit under tmux
Summary: >=app-portage/eix-0.24.0 doesn't clear status on exit under tmux
Status: RESOLVED CANTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Martin Väth
URL:
Whiteboard:
Keywords:
: 465074 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-03-08 21:24 UTC by octoploid
Modified: 2018-01-05 09:41 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description octoploid 2012-03-08 21:24:40 UTC
Since 0.24 eix-update displays what it is doing on the 
status bar when run under tmux.
It doesn't however clear its status on exit.
The result is the following:
 0:su- 1:eix-update: Finished* 2:log  3:ncmpcpp ...
As you can see screen number 1 still shows the status after 
eix-update finished instead of "su".


Reproducible: Always
Comment 1 Reinis Danne 2012-03-08 21:38:17 UTC
The same with byobu and screen as backend.
Comment 2 octoploid 2012-03-08 21:57:52 UTC
This is what weechat does, maybe it can be adopted:

void
gui_window_set_title (const char *title)
{
    char *shell, *shellname;
    char *envterm = getenv ("TERM");
    char *envshell = getenv ("SHELL");

    if (envterm)
    {
        if (title && title[0])
        {
            if (strcmp (envterm, "sun-cmd") == 0)
            {
                printf ("\033]l%s\033\\", title);
            }
            else if (strcmp (envterm, "hpterm") == 0)
            {
                printf ("\033&f0k%dD%s", (int)(strlen(title) + 1), title);
            }
            /* the following term supports the xterm excapes */
            else if ((strncmp (envterm, "xterm", 5) == 0)
                     || (strncmp (envterm, "rxvt", 4) == 0)
                     || (strcmp (envterm, "Eterm") == 0)
                     || (strcmp (envterm, "aixterm") == 0)
                     || (strcmp (envterm, "iris-ansi") == 0)
                     || (strcmp (envterm, "dtterm") == 0))
            {
                printf ("\33]0;%s\7", title);
            }
            else if (strncmp (envterm, "screen", 6) == 0)
            {
                printf ("\033k%s\033\\", title);
                /* trying to set the title of a backgrounded xterm like terminal */
                printf ("\33]0;%s\7", title);
            }
        }
        else
        {
            if (strcmp (envterm, "sun-cmd") == 0)
            {
                printf ("\033]l%s\033\\", "Terminal");
            }
            else if (strcmp (envterm, "hpterm") == 0)
            {
                printf ("\033&f0k%dD%s", (int)strlen("Terminal"), "Terminal");
            }
            /* the following term supports the xterm excapes */
            else if ((strncmp (envterm, "xterm", 5) == 0)
                     || (strncmp (envterm, "rxvt", 4) == 0)
                     || (strcmp (envterm, "Eterm") == 0)
                     || (strcmp( envterm, "aixterm") == 0)
                     || (strcmp( envterm, "iris-ansi") == 0)
                     || (strcmp( envterm, "dtterm") == 0))
            {
                printf ("\33]0;%s\7", "Terminal");
            }
            else if (strncmp (envterm, "screen", 6) == 0)
            {
                if (envshell)
                {
                    shell  = strdup (envshell);
                    if (shell)
                    {
                        shellname = basename (shell);
                        printf ("\033k%s\033\\", (shellname) ? shellname : shell);
                        free (shell);
                    }
                    else
                    {
                        printf ("\033k%s\033\\", envterm);
                    }
                }
                else
                {
                    printf ("\033k%s\033\\", envterm);
                }
                /* tryning to reset the title of a backgrounded xterm like terminal */
                printf ("\33]0;%s\7", "Terminal");
            }
        }
        fflush (stdout);
    }
}
Comment 3 Richard Grenville 2012-03-09 00:30:01 UTC
eix-update tries to set the "name" of the window, overriding the name tmux automatically set with "automatic-rename", which is truly annoying for me, too. Anyway, I used this in .tmux.conf to solve the issue:
  setw -g allow-rename off

It would prevent other applications from setting the window name, too. Anyway, they still have "title" to mess up.
Comment 4 Martin Väth 2012-03-09 14:51:38 UTC
It is not possible to get the previous status line:
No program which sets the status line can "clear" it.
(Well, it can set an empty title, but this would give you an empty
string instead of "su -" in your example.)

For instance, also emerge only sets some "random" status line on exit.
The current exit text (describing the status) appears to be
the most reasonable.

If you have a good prompt, it should set the title by itself when
the prompt appears again. ;)

If you do not want that an eix tool changes the statusline, set
NOSTATUSLINE=true
(in /etc/eixrc or in your environment) or adopt the
TERM_{SOFT,}STATUSLINE
values to your needs (see eix --dump).
Comment 5 octoploid 2012-03-09 15:20:18 UTC
(In reply to comment #4)
> It is not possible to get the previous status line:
> No program which sets the status line can "clear" it.
> (Well, it can set an empty title, but this would give you an empty
> string instead of "su -" in your example.)
> 
> For instance, also emerge only sets some "random" status line on exit.
> The current exit text (describing the status) appears to be
> the most reasonable.

No. As you can see in the code snipped above, sane programs
set the status line to the name of the shell when they exit.
This is better than leaving the long exit text forever...
Comment 6 Martin Väth 2012-03-09 17:25:00 UTC
(In reply to comment #5)
> No. As you can see in the code snipped above, sane programs
> set the status line to the name of the shell when they exit.

The fixed string "Terminal" or the $SHELL environment variable
(which is not even set in every shell, even less exported; not to speak
that especially in screen/tmux the program need not have been called
from a shell) is as sane as any other random choice of text like
"${USER}@${HOST}:${PWD}" (as in portage) or a
success/failure text (as in eix).
The latter at least contains some real information.

I think it would be overdone to make this final string configurable,
but OTOH eix has configure variables for almost everything, anyway.
Comment 7 Martin Väth 2012-03-20 22:07:27 UTC
Just for the records, since it came up on a mailinglist:

Since eix-0,25.1 there is an EXIT_STATUSLINE variable.
You can set it e.g. in /etc/eixrc to any (fixed) exit statusline you want
if you do not agree with the default
(An optional leading space is ignored so that e.g. EXIT_STATUSLINE=" "
will give you an empty exit statusline).

I guess that this configuration option is about the best which can be
done about the problem.
Comment 8 Martin Väth 2013-04-09 07:16:06 UTC
*** Bug 465074 has been marked as a duplicate of this bug. ***