The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 290,096β€…    Votes:  30β€…
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: April 8, 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"


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 \.

⇧ How do I enable docker as a service without re-installing docker? Long kernel load time  β‡©