Set the terminal tab title as prompt name in unix Set the terminal tab title as prompt name in unix unix unix

Set the terminal tab title as prompt name in unix


Many terminals emulators are able to understand the special escaping : "\033]0;foo\007".


I know its a old post but i saw it today :Here is the answer:

title `pwd`

if title command does not works in your shell then:

  1. write a shell script with follwing contents (filename = title)
#!/usr/bin/tcsh -fecho "^[]2;$1^G^[]1;$1^G"
  1. then:
chmod +x title (give this script executable permission)
  1. type:
title `pwd` <enter>


This single line command will change the title of the tab.

  1. Simply run the command from terminal tab which title need to change-
    PS1=$PS1"\[\e]0;My_Tab_Name\a\]"

Some Info:The PS1 is a primary prompt variable which holds the characters displayed at the terminal prompt. You can set it whatever you want. However the above command will make it only work for current terminal session. Once you close the terminal and opena new one, it'll be the default one.

To make it permenant edit the PS1 variable in ~/.bashrc or ~/.zshrc file.

Benefits-
It help us to easily navigate over the tabs.