I got this solution by experimenting with others like @ flurin-arner for example. I ran the @ weston-ganger set-title () set . I also used the @ imgx64 PROMPT_DIRTRIM clause . I also use the @itseranga git branch tooltip, although this has nothing to do with the question, which shows what you can do with the tooltip.
First, as shown by Weston and above
TITLE="\[\e]2;$*\a\]"
can be used to manually set the terminal header, "$ *" is command line input, but not what we want.
Secondly, as I said, I also add git branch to my tooltip, again not part of the question.
export PROMPT_DIRTRIM=3 parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
Thirdly, experimentally I copied the TITLE code above, set $ * to a fixed line and tried this:
see: \[\e]2;'SomeTitleString'\a\] export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\[\e]2;'SomeTitleString'\a\] $ "
It had the desired effect! Ultimately, I wanted to use the base path as the title. PS1 Params shows that \ W is the base path, so my solution is this:
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\[\e]2;\W\a\] $ "
without git branch:
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\[\033[00m\]\[\e]2;\W\a\] $ "
the result is a prompt with git-branch:
user@host ~/.../StudyJava (master) $
the result is an invitation without parse_git_branch:
user@host ~/.../StudyJava $
where pwd gives
/home/user/somedir1/otherdir2/StudyJava
and terminal name
StudyJava
NOTE. Starting with @seff, I essentially replace "My Title" with "\ W"
export PS1='\[\e]0;My Title\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '