set terminal title in Ubuntu

The option to set the terminal title has been deprecated in 16.04 LTS, however there is still a way to set the title. Edit your ~/.bashrc file and add the following lines:
# function to set terminal title
function set-title(){
if [[ -z "$ORIG" ]]; then
ORIG
=$PS1
fi
TITLE
="\[\e]2;$*\a\]"
PS1
=${ORIG}${TITLE}
}
After that close and reopen the terminal or source your .bashrc (command: source ~/.bashrc) and you can set the title by simply typing:
set-title "<title>"

1 Comments

Thank You

Previous Post Next Post