1

I can install xtitle on Ubuntu WSL, however, this package is not available on CentOS WSL (possibly also CentOS itself).

Install xtitle on Ubuntu:

sudo apt install xtitle -y

These commands won't install xtitle on CentOS:

sudo yum install xtitle -y
sudo dnf install xtitle -y

Any work-arounds?

2 Answers 2

2

The 'xtitle' program only outputs these "escape sequences", so it can be replaced with 'echo -e' or 'printf' or similar functions in any programming language:

printf '\e]0;%s\e\\' "My title here"

(The closing sequence can be either \e\\ (ESC \) or \a (BEL); the former is more correct but the latter is more widespread, although most terminals support both.)

1

printf or echo -e to set terminal title won't work if PS1 (prompt for shell 1) is set.

The following command set text in title bar and also prompt:

export PS1="\e]0;TITLE\a\u@\h:\w\n$ "

The title bar is set as 'TITLE' and prompt shows up as, for example:


user@server:\some\path
$ _

Put this function xtitle in .bashrc or /etc/profile:

#The '\e]0;$1\a' is to make the title in title bar
#The rest is the prompt
function xtitle {
  export PS1="\e]0;$1\a\n\u@\h:\w\n\$ ";
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .