I got this solution from experimenting with others, like @flurin-arner I started the @weston-ganger set-title(). I also used @imgx64 PROMPT_DIRTRIM suggestion. I m also using @itseranga git branch prompt, though this has nothing to do with the question it does show what you can do with the prompt.
First as shown by weston and above
TITLE="[e]2;$*a]"
can be used to manually set the Terminal Title, "$*" is commandline input, but not what we want.
2nd as stated I m also adding git branch to my prompt, 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 [ 33[32m]w[ 33[33m]$(parse_git_branch)[ 33[00m] $ "
3rd, by experiment I copied the TITLE code above, set the $* to a fixed string and tried this:
see: [e]2; SomeTitleString a]
export PS1="u@h [ 33[32m]w[ 33[33m]$(parse_git_branch)[ 33[00m][e]2; SomeTitleString a] $ "
This had the desired effect! Ultimately, I wanted the base path as my title.
PS1 Params shows that W is the base path so my solution is this:
export PS1="u@h [ 33[32m]w[ 33[33m]$(parse_git_branch)[ 33[00m][e]2;Wa] $ "
without the git branch:
export PS1="u@h [ 33[32m]w[ 33[33m][ 33[00m][e]2;Wa] $ "
resulting in a prompt with git-branch:
user@host ~/.../StudyJava (master) $
resulting in a prompt without parse_git_branch:
user@host ~/.../StudyJava $
where pwd gives
/home/user/somedir1/otherdir2/StudyJava
and Terminal Title
StudyJava
NOTE: From @seff above I am essentially replacing the "My Title" with "W"
export PS1= [e]0;My Titlea]${debian_chroot:+($debian_chroot)}u@h:w$