Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've selected "Replace initial title" setting in gnome-terminal's preferences, but it just shows the default title "Terminal". After reading this answer, I added this to my .bashrc:

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

and also commented out this line:

#PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

After restarting terminal, it started to show user@hostname: ~/currentdir in its title, changing it whenever I cd to another directory. But it still does not change when I launch CLI programs like cmus and vim (vim, for example, sets current filename as a title).

I've installed rxvt and everything works fine there.

Ubuntu 13.04, gnome-terminal 3.6.1.

My .bashrc - almost the same as shipped with default ubuntu installation.

Screenshot of terminal

share|improve this question
    
Looks like a bug... –  edwin Aug 5 '13 at 16:40
    
Read the comments of the answer you prosted and try to comment out the relevant PROMPT.. –  topless Aug 7 '13 at 9:36
    
I a software like VIM or cmus issue a command to change the title, the title will be changed... You can set the initial title only. –  Alex Aug 9 '13 at 1:51

3 Answers 3

up vote 2 down vote accepted
+50

First, you have something contradictory in your question. You said, "it started to show user@hostname: ~/currentdir in its title, changing it whenever I cd to another directory", but the image attached said something else. I am almost sure that if you've selected "Replace initial title" setting in gnome-terminal's preferences and if you use this ~/.bashrc file as you said, your terminal should look like in the following image:

galymzhan@atom

Second, you're totally wrong with: "vim, for example, sets current filename as a title". To do this, you must to heve a file named .vimrc in your home directory with the following code inside:

let &titlestring = $USER . "@" . hostname() . ": vim " . expand("%:t")
if &term == "screen"
  set t_ts=^[k
  set t_fs=^[\
endif
if &term == "screen" || &term == "xterm"
  set title
endif

And one more thing: I don't understand yet exactly for what do you using that if from the 11th line until 40th line in your .bashrc file, but setting up TERM="gnome-256color" at the line 33 may be a problem in this case. So, I suggest you to comment that line, or to remove all the code between lines 11 and 40.

After all of this done, when you will use vim, your terminal should look like:

galymzhan@atom: vim

share|improve this answer
    
I posted screenshot before modifying bashrc, sorry for confusion. Anyway, those lines 11-40 were indeed the cause of this problem. They are needed to set correct xterm variable (like gnome-256color), but for now I'll stick with default xterm value. –  galymzhan Aug 9 '13 at 12:52

Here's what works for me:

  1. Install the xttitle package.
    sudo apt-get install xttitle
  2. Add to ~/.bashrc:
    PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[1;31m\]($?)\[\033[00m\]\$ '

  3. Add to .bashrc

    # from the "xttitle(1)" man page - put info in window title  
    update_title()   {  
      [ $TERM = xterm -o $TERM = xterm-color ] && xttitle "[$$] ${USER}@${HOSTNAME}:$PWD"
    }  
    cd()
    {  
      builtin cd "${@}"
      update_title
    }
    
share|improve this answer

Just to be certain, when you edited the default profile, did you try to save that configuration? Shut the terminal, and then re-opened it? Did it fail?

The normal, out-of-the-box install does replace the initial title in my experience, so I am a little surprised by the issue.

Try this method:

  1. Open a terminal
  2. on the tollbar at the top of the screen click on Edit > Profiles
  3. Select the Default profile
  4. Click on the 'Edit' button with the Default profile highlighted
  5. Click on 'Title and Command' Tab
  6. Insure that the 'Replace Initial Title' button is visible
  7. Click the 'Close" button on each screen to go back to the terminal
  8. Exit the terminal
  9. Restart a terminal session

You should have the title automatically replaced with your unique username and path in your home directory.

share|improve this answer
    
I did everything as you described and still no luck. By the way, is it possible to be a unity issue? I've added screenshot to the post –  galymzhan Aug 6 '13 at 4:50
    
Do you use Unity? Personally do and it works and always has. At this point, all of the additions to your .bashrc have probably affected the output in ways that are not as normal if you are using the method described. Further editing is likely to compound the issue versus using the standard, out of the box configuration. One way to test for certain: create another user, try the method described above and see if it works. –  freecode Aug 7 '13 at 15:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.