views:

218

answers:

4

Hi all. I recently added these lines to my ~/.bashrc file to show the current branch if i'm in a git working folder, and it works nicely for that. However, what i've lost is that the current folder name used to be shown in the tab for the terminal i have open, and now it isn't: it always just says 'Terminal'. Can i get that back and still keep the git stuff? Here's the lines in question - it's the second one that's the issue, as commenting out just the second line fixes the problem.

source /etc/bash_completion.d/git
PS1='\h:\w$(__git_ps1 "\[\e[32m\][%s]\[\e[0m\]")$ '

I've been looking at explanations of the options for PS1 but can't see anything about the terminal window's title in there. Can anyone advise? thanks, max

+2  A: 

That's what I have as default on my Ubuntu concerning the terminal's title:

PS1='\[\e]0;\u@\h: \w\a\]'

Prepend your PS1 with this one and it should be fine

Romuald Brunet
Perfect, thanks Romuald!
Max Williams
+2  A: 

You can try:

PS1="$PS1"'\h:\w$(__git_ps1 "\[\e[32m\][%s]\[\e[0m\]")$ '

But it would help to know what PS1 is being set to earlier in ~/.bashrc or in /etc/bash.bashrc.

Dennis Williamson
A: 

Another way to do this is to use PROMPT_COMMAND and let PS1 just be the prompt. For example:

PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'

Joe Wahoo
A: 

I use this:

PROMPT_COMMAND='echo -ne "\033]0;${PWD/$HOME/~} - ${USER}@${HOSTNAME}\007"'

which results in a window title like this:

/home/tkirk - tkirk@hostname
Trampas Kirk