The Cookie Machine - Click here to drag window

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

Views: 266,007β€…    Votes:  20β€…
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:  February 27, 2022
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


Works on Ubuntu 16.04 to 20.04

This answer is simpler than most others. To use it, you would simply 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  β‡©