Announcement

Collapse
No announcement yet.

Xterm window title

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Xterm window title

    How do I set the Xterm window title? I'm using 8.04.

    When I log into some machines the window title gives the host name of the machine that I'm logging into. That is what I prefer. However sometimes it still only shows the name of the one I'm on. The question is, how do I make it always show the hostname of the server?


    #2
    Re: Xterm window title

    put this in your

    .bashrc

    (or equivalent)


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

    (I mean the .bashrc of every account you want to log into)

    Comment


      #3
      Re: Xterm window title

      Thanks for answering sanette, but I don't understand your answer. I don't understand what the server has to do with this. I'm just talking about the client.

      Comment


        #4
        Re: Xterm window title

        If I understand what you are doing, you work in an xterm and login into a remote machine.
        When you do this, the config files of your personal account in the remote machine are executed.
        Very often, these files will re-set the title of your xterm window.

        If this does not make sense to you, please describe more precisely what you are doing, it would be easier for me to try to help.

        Comment


          #5
          Re: Xterm window title

          Thanks for trying to help sanette. I have a feeling that I am missing something fundamental in my own understand about this. What I am doing is working in Xterm on my computer, then I am using telnet to log into others. When I log into my Linux machines, I see the name of the machine in the window title. That is very handy when I have numerous terminals open and switching between them. I had not noticed any problem before because the other machines were all Linux, however now 3 of them are FreeBSD and they don't do the same. Typically I don't log into my own account on these machines so it didn't make sense to me to change any configuration there, but perhaps that is the only solution.

          Examples:
          When I log in as eileen on a Linux box called CDX the window title says
          eileen@CDX
          When I log in as eileen on a BSD box called TOP the window title says
          ole@SCO
          which is the machine I'm working on. That's very confusing when tabbing through terminals.

          All machines have properly configured (AFAIK) network connections and respond properly with their host names etc. So, is the only way to get my Xterm to show the "right" thing acomplished by editing the shell parameters on the server side? I had expected (perhaps wrongly) that the window title would be showing the host name as per the network configuration.






          Comment


            #6
            Re: Xterm window title

            I don't know much about telnet, but if it behaves like ssh, then when you telnet to open a connection to a remote machine (for instance TOP) the shell of the remote machine is probably executed. If the shell is bash, then the remote .bashrc is executed.

            what is your remote shell ?

            what happens if after login to TOP, you type

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

            or simply

            PROMPT_COMMAND='echo -ne "\033]0;BLABLA\007"'

            or even simply

            echo -ne "\033]0;BLABLA\007"

            Comment


              #7
              Re: Xterm window title

              Originally posted by sanette
              I don't know much about telnet, but if it behaves like ssh, then when you telnet to open a connection to a remote machine (for instance TOP) the shell of the remote machine is probably executed. If the shell is bash, then the remote .bashrc is executed.
              I see, the remote shell needs to be executed locally. Of course. I didn't think of that. This is all starting to make more sense now. Thanks!

              As for telnet, it is standard for mobile communications, mainframes, industrial controls, BBSs, and gaming (among others) but from what I can see, it works effectively just like SSH. Also, telnet in Linux sends passwords encrypted if the remote is capable, so for most purposes telnet and SSH are indistinguishable in Linux.

              what is your remote shell ?

              what happens if after login to TOP, you type

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

              or simply

              PROMPT_COMMAND='echo -ne "\033]0;BLABLA\007"'

              or even simply

              echo -ne "\033]0;BLABLA\007"
              My remote shell varied, but now I have it set to tcsh on the BSD machines. Tcsh apparently should work like csh for the most part. Doing the first two commands you list, does nothing but say wrong command - the last one seems to do nothing. Typing "hostname" elicits the right response, so I do think you are on the right track with putting that in the prompt. I also should say that the xterm I'm using is in KDE and reports itself as "Konsole 1.6.6 (Using KDE 3.5.10) X terminal for use KDE."

              In looking at the net for more information I came across this site: How to change the title of an xterm. This is starting to become way too complicated! Perhaps this is more work than it is worth for now. Instead, I have found that clicking on "View" (not edit!) on the terminal window top bar, I can "rename session" (also Ctrl-Alt-S) and it will add whatever I write to whatever is already there in the window top bar. That is not exactly what I was looking for, but provides some functionality for distinguishing terminals and is easy to do. It's a bit clunky, but it works.



              Comment


                #8
                Re: Xterm window title

                ah... you should have said that you use konsole and not a true xterm.
                konsole has only a partial xterm emulation...
                and indeed the standard "escape sequence" for changing the title doesn't work for konsole...

                EDIT: in fact, my default setting for konsole just ignores the title set by the terminal. But you can change this:
                in the menu:
                Config-->Modify Profiles--> Tabs
                you can define the title. If you want to use the title set by the terminal, use %w
                But you could also try %n, which uses the name of the current command

                (I'm using KDE 4, I'm not sure this is the same in KDE 3.5)

                Also, that's normal that you get a "command not found" since the syntax of tcsh is not the same as bash.

                Once you have set the "%w" above in konsole config, try in your tcsh

                echo "\033]0;${USER}@${HOST}\007"

                This should change your window title.

                You can change both the prompt and the window title as follows:

                set prompt="%{\033]0;%n@%m:\007%}$HOME%# "

                Comment


                  #9
                  Re: Xterm window title

                  Originally posted by sanette
                  ah... you should have said that you use konsole and not a true xterm.
                  konsole has only a partial xterm emulation...
                  and indeed the standard "escape sequence" for changing the title doesn't work for konsole...
                  Sorry, I'm confused because Kubuntu keeps changing over the years and I don't really have the mental capacity to keep up. It does indeed say "K"onsole at the top now. As for partial emulation, that makes sense, it has some fatal bugs too. However, since I need to run a GUI for the browser, I find that a GUI terminal is handy. Besides the Konsole implementation has what to me is one of the most readable screens since the 5051.




                  EDIT: in fact, my default setting for konsole just ignores the title set by the terminal. But you can change this:
                  in the menu:
                  Config-->Modify Profiles--> Tabs
                  you can define the title. If you want to use the title set by the terminal, use %w
                  But you could also try %n, which uses the name of the current command

                  (I'm using KDE 4, I'm not sure this is the same in KDE 3.5)
                  Hmm, it doesn't look like there is any GUI configuration of the terminal in KDE 3.5. I've been looking for a long time now. No "Config" no "Modify Profiles" and no "Tabs". At least not in system settings or the Konsole menus. A configuration file would really be a nice user friendly thing right about now.


                  Also, that's normal that you get a "command not found" since the syntax of tcsh is not the same as bash.

                  Once you have set the "%w" above in konsole config, try in your tcsh

                  echo "\033]0;${USER}@${HOST}\007"

                  This should change your window title.

                  You can change both the prompt and the window title as follows:

                  set prompt="%{\033]0;%n@%m:\007%}$HOME%# "
                  I'll check that out later. Especially because it will be useful for other than Kubuntu. However, for now I need to figure out how to find "konsole config" in Kubuntu.

                  Comment


                    #10
                    Re: Xterm window title

                    I checked with konsole/KDEE 3.5.10, and when I type

                    PROMPT_COMMAND='echo -ne "\033]0;BLABLA\007"'

                    (in the local bash shell, no connection)

                    it does change the title of the window to "BLABLA".



                    Comment


                      #11
                      Re: Xterm window title

                      Ole Juul, I don't want to hijack this thread, but I have a related question. How can I change the font color of my name in front of the prompt in Gnome Terminal Emulator or in Konsole. It comes up a sickly light green in both and I can't figure out how to change it. Using the profile settings allows me to change the font and background of input and out put but it doesn't change the color of the part preceding the prompt.


                      Uploaded with ImageShack.us

                      Comment


                        #12
                        Re: Xterm window title

                        Welcome to the party Detonate. I like a red prompt and green type. That way it is easy to see where the divisions are when looking at the stuff that's scrolling away. On my 8.04 system I edited my .bashrc file in my home directory. IIRC, there is a part to comment out and a part to comment in, as it were. The file is well commented (oh dear, I'm getting tired) so it is not too difficult. Having a quick look I think this is the bit that does the trick:
                        Code:
                        # Comment in the above and uncomment this below for a color prompt
                        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;31m\]\w
                        \[\033[00m\]\$ '
                        I need to sleep, but I'll be back tomorrow evening. To see if that worked, and answer sanette.

                        Comment


                          #13
                          Re: Xterm window title

                          I can't get it to change. I've tried different numbers in PS1 line but nothing happens. Here is the pertinant part of my .bashrc file. What am I not doing correctly?

                          # set a fancy prompt (non-color, unless we know we "want" color)
                          case "$TERM" in
                          xterm-color) color_prompt=yes;;
                          esac

                          # uncomment for a colored prompt, if the terminal has the capability; turned
                          # off by default to not distract the user: the focus in a terminal window
                          # should be on the output of commands, not on the prompt
                          #force_color_prompt=yes

                          if [ -n "$force_color_prompt" ]; then
                          if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
                          # We have color support; assume it's compliant with Ecma-48
                          # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
                          # a case would tend to support setf rather than setaf.)
                          color_prompt=yes
                          else
                          color_prompt=
                          fi
                          fi

                          if [ "$color_prompt" = yes ]; then
                          PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
                          else
                          PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
                          fi
                          unset color_prompt force_color_prompt

                          Comment


                            #14
                            Re: Xterm window title

                            Originally posted by Detonate
                            #force_color_prompt=yes
                            You need to uncomment the above line.
                            Windows no longer obstructs my view.
                            Using Kubuntu Linux since March 23, 2007.
                            "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                            Comment


                              #15
                              Re: Xterm window title

                              That did not do it. No matter what changes I make to .bashrc, everything stays the same.

                              Comment

                              Working...
                              X