3

On Ubuntu, I usually open more than one Emacs instances in the same time (for frontend and back development). These instances always by default take the name "Terminal" as a title as shown on this screenshot:

enter image description here

Is there a handy way to change that title?

Emacs is running inside a Gnome terminal.

  • 1
    See also emacs.stackexchange.com/questions/41309/… – andrej Dec 24 '18 at 8:52
  • 1
    @andrej can you add these as an answer to your question? – DoMiNeLa10 Dec 24 '18 at 11:30
  • 1
    @BillalBegueradj Is this what we see in the screenshot emacs in the Terminal? Then emacs doesn't seem to be the right place to look at. Then this askubuntu.com/questions/636944/… seems to be more relevant. – andrej Dec 24 '18 at 14:04
  • 1
    @andrej You might still want to have Emacs set the terminal title, for example to show the current file name. – Gilles Dec 24 '18 at 14:30
  • 2
    Why not run a GUI Emacs? More things work out of the box with a GUI Emacs, including the window title. – Gilles Dec 24 '18 at 14:30
3

A bit of terminology that can help you find help and documentation: for historical reasons, what the rest of the world calls a window is called frame in Emacs. What Emacs calls a window is what the rest of the world sometimes calls a pane. The same metaphor grew in different directions.

Emacs automatically sets its operating system window title (i.e. the title of the Emacs frame) to emacs@darkstar (where darkstar is the host name of the machine it's runnning on) if there's a single Emacs window, and to the buffer name if there are multiple windows. (That's multiple windows in the same instance.) However, this only applies to the title of Emacs windows, i.e. when running a GUI instance of Emacs. If you run Emacs inside a terminal, Emacs doesn't set the terminal's title out of the box.

The Emacs wiki gives a solution when Emacs is running in an xterm-like terminal. Most Unix terminal emulators, including Gnome Terminal, are xterm-like. Install the packages xterm-frobs.el and xterm-title.el (not available from a package repository that I can find) and put the following code in your init file:

(require 'xterm-title)
(xterm-title-mode 1)

Then when Emacs is running in a terminal, it will try to set the terminal emulator's title.

To configure the text that goes into the title, configure the variable frame-title-format. For example, to always show Emacs: buffer name regardless of whether there are multiple frames, use

(setq frame-title-format "Emacs: %b")

If you want to give a specific title to a specific window, use the command set-frame-name.

2

As far as I understand from the comments you want to change the title of the emacs window running in the terminal. So in fact you want to change the title of the terminal.

In this case go to Menu: Terminal --> Set Title --> Enter new title then save. It should also be possible to do it using a shortcut which may depend on your system. (This is from https://askubuntu.com/questions/636944/how-to-change-the-title-of-the-current-terminal-tab-using-only-the-command-line where more suggestions are made.)

Just for the record: If you want to change the title of a GUI Emacs window, then the variable you want to change is frame-title-format. See emacswiki.org/emacs/FrameTitle for some examples. See also How to make frame-title-format persistent?

You can also evaluate the following

(modify-frame-parameters nil (list (cons 'name "new name"))) 

in the scratch buffer to rename the frame you are in to "new name". You can also define a function and bind it to a shortcut. Here nil means that the default frame i.e. the frame you are in is renamed.

Comment: This works for me, but I am not sure if this is a suitable way to use modify-frame-parameters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.