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.

| improve this question | | | | |

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.

| improve this answer | | | | |
  • On emacs 28.0.50 and Ubuntu 19.10, xterm-title-mode appears to block until you C-g, and doesn't change the title. – Joseph Garvin Mar 29 at 20:49

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.

| improve this answer | | | | |

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.