[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: A bug in Vim, in Mate Terminal or in Debian 11?



On Sat, Sep 18, 2021 at 10:23:06PM -0400, Greg Wooledge wrote:
> On Sat, Sep 18, 2021 at 10:14:39PM -0300, Dedeco Balaco wrote:
> > My window manager is Mate Desktop. The terminal i most use is its own.
> > And i use vim a lot,

[...]

> Vim has another setting called "titleold".  If this is set to a non-empty
> string, vim will use the value of this variable as the new title.  So,
> for example, if you would like the title to be changed to "Terminal"
> every time you exit vim, you can put these lines in your .vimrc file:
> 
> set title
> set titleold=Terminal
> 
> If titleold is set to the empty string, then the title isn't changed at
> all on exit -- it just stays as the filename.
> 
> If there's a *third* option (to make vim somehow read the previous title
> from the terminal, if that's even possible), then I don't know how to
> achieve it.  It would probably be specific to the terminal as well.
> 
> If you want more answers than this, I suggest asking on a vim mailing
> list.  They may have more expertise than we do.
> 
> A *fourth* option that some people use is to have their shell change the
> terminal's title on a regular or semi-regular basis [...]

I've no Mate terminal here (just plain xterm), but this fourth way is
the one Debian chose for me: the shell prompt (via the PS1 variable)
is the one working the magic. I guess Mate terminal works as Xterm
here.

It's defined to be

  tomas@trotzki:~$ echo $PS1
  \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$

Now it's a bit tough to read with all that escape voodoo (part of this
are "real" escapes sent to the terminal, part of them are interpreted
by the shell while preparing the prompt string out of this mumbo-jumbo
template) but I'll try (the PROMPTING section from the bash manual
is of help here). Those digested by the shell prompt I label with [P],
those passed through to the term as escape sequences with [E] (cf.
[1] for the latter):

  \[        ->  [P]              begin sequence of non-printing chars
  \e]0;     ->  [E] ESC ] 0 ;    (Xterm) set window title
  \u        ->  [P]              useername
  @         ->                   literal @
  \h        ->  [P]              hostname
  :         ->                   again, a literal
  [space]   ->                   literal (this gets boring :)
  \w        ->  [P]              current working directory (CWD)
  \a        ->  [E]              bell: close "set window title" escape
  \]        ->  [P]              end sequence of non-printing chars

...the rest is boring prompt matter. What this cooks down to is to
set the terminal title to <username>@<host>: <cwd>.

This has to be done at every prompt, otherwise the title wouldn't
"follow along" when I do cd, for example (or when I ssh into
another host).

When exiting vim, a new prompt is issued, so this is the one which
should take care of this.

So Dedeco -- I'd look into whatever is providing your shell prompt
as a first guess.

Cheers

[1] https://en.wikipedia.org/wiki/ANSI_escape_code

 - t

Attachment: signature.asc
Description: Digital signature


Reply to: