Views:
296,719β
Votes: 31β
Tags:
command-line
gnome-terminal
titlebar
Link:
π See Original Answer on Ask Ubuntu β§ π
URL:
https://askubuntu.com/q/1164880
Title:
How to change Gnome-Terminal title?
ID:
/2019/08/11/How-to-change-Gnome-Terminal-title_
Created:
August 11, 2019
Edited: June 15, 2023
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
Works on Ubuntu 16.04 to 22.10
This answer is simpler than most others. To use it, you would just type:
title "My new title"
- Easier to remember than most other answers.
- The accepted answer and others do not work on modern versions of Ubuntu (from 16.04 on up).
- This answer doesnβt require 3rd party packages like
wmctrl
andxdotool
. - Version 2 allows running multiple times in the same session.
One-time function creation
Create the title
function in your ~/.bashrc
file:
function title() {
# Set terminal tab title. Usage: title "new tab name"
prefix=${PS1%%\\a*} # Everything before: \a
search=${prefix##*;} # Eeverything after: ;
esearch="${search//\\/\\\\}" # Change \ to \\ in old title
PS1="${PS1/$esearch/$@}" # Search and replace old with new
}
Save the ~/.bashrc
file. After opening a new terminal tab use:
title "Special Projects"
or:
title Special\ Projects
A phrase with spaces must be wrapped in double quotes ("
) or each space must be escaped with \
.