0

Question

I have a script called title which sets the title bar for a UNIX window, it's simple and just echos an escape sequence. See https://askubuntu.com/a/22417/323009.

#/bin/bash
ESC=$'\e'
BELL='$'\a'
echo "${ESC};$*$BELL"

To use it I just type:

title tomcat logs

To make this work, however, I must also change the default PS1 setting because it breaks title because the default PS1 updates your title.

But I don't currently set PS1 in my $HOME/.bashrc file and I like the way PS1 works, I just want to stop PS1 from also updating my window title. What's the fix?

Is there a way to tell Ubuntu to manage PS1 the way it does but without updating my title?

Work Around

My current work around is to manually do this by finding how it's currently set.

echo $PS1

And then editing it so it removes the escape sequence which is updating the title.

PS1="\u@\h \w: "

The solution I'd like to have

By this day and age, I would have expected this to be configurable so that I could say in my .bashrc file. NOTE: Putty allows this to be changed, see https://superuser.com/a/919770/331605

DONT_UPDATE_TITLE=true
 . . . rest of normal .bashrc file

And the code that sets PS1 would not update the title but continue updating the PS1 prompt as it currently does.

Searching for a solution

There are many questions asking similar questions but none asking this one.

Below are links I've found helpful some in StackOverflow, Ubuntu, and Superuser.

PatS
  • 115

1 Answers1

1

PS1 can be set in your ~/.bashrc. If it isn't, you get the PS1 that was set earlier (see "Startup Files" in man bash.

The values you set into PS1, and their effects, is documented in man bash, the section on "Prompting".

Look at what is in your PS1 with echo "$PS1" | od -bc.

Aside from PS1, when I want this behavior (update title upon cd), I replace the cd command with a bash function, defined in my ~/.bashrc, that does the cd and sets the title. See type cd to check if your cd command has been replaced. The function that replaced cd was defined in one of the startup files, see paragraph 1.

waltinator
  • 36,399
  • The question I'm asking is this: Is it possible to set a value (variable) in my .bashrc that causes the default system files that currently set PS1 to work as they do now, but without setting the window title? – PatS Sep 20 '23 at 13:41