Change Terminal Title

Is it possible to change the title of a Terminal window on Solaris? For example, for a MS Windows command window, one can simply type "title NameofWindow" to change the title for a command window.

I was looking for similar functionality for terminal windows.

Thanks.

Ahhhh...c'mon....please don't tell me that this isn't possible or isn't as seamless as it is on Windoze ???

here2learn,

Although it is possible, I, for one, don't have the time to check into it - I do know it's set up somewhere in a login for it changed my title yesterday - but I could not find where when I went back to the same systems in a new window (whatever I did as far as logging in didn't change the second window). And that was all the time I had to spend on this as real work was keeping me busy.

Another thought - look at this - your second post may be considered for #4.

And if you are really here2learn, look at #5.

$ dtterm -title NameofWindow

if u use xterm:

$ xterm -T NameofWindow

Does this help?

local xterm:
xterm -sb -T windowTITLE -geometry 131x64+100+0 -fn fixed -bg gray -fg black -cr blue -e

xterm via ssh:
xterm -sb -T productionBOX -geometry 131x64+100+0 -fn fixed -bg gray -fg black -cr blue -e ssh productionBOX

xterm via telnet:
xterm -sb -T developmentBOX -geometry 128x65+100+0 -fn fixed -bg black -fg green -cr yellow -e telnet developmentBOX

That's what I'm talking about !!! The color tip is awesome !!! Would there actually be away to configure the terminal window to always startup with a certain color?

Thanks for the info.

PS. - Sorry RTM. I did do a search on here prior to posting. I'm usually very hesitant on posting until I do an exhaustive search. Guess I should have search a little harder. Apologize about the bumping.

here2learn - not a problem. Sometimes the searching can be difficult - you have to know what someone else may have posted - this should have come up for you in a search for terminal title

Dude, it's UNIX... you can do whatever you want. Here's some functions that should work in ksh or bash. Notice that if you put this in your .bashrc or .kshrc file using vi, you would create the "^[" by pressing control-V and then the Escape key. ^G is created by control-V and then control-G. All other characters are verbatim, and are the property of their owners.

wt changes the window title on the fly. Use it like: wt anything you want
it changes the window title and the icon title. Usage: it anything you want
defwt is my default window title, it shows you how to put a shell function in the window title.
cls is clear screen. Xterms are like vt100's, so it will work.

These functions work for many other vt100 emulators, I have found.

This is for Sun's echo command, which takes a \c to tell you not to send a carriage return at the end. For Linux you have to use its version. I think echo is deprecated and you want to use printf, but I'm not in front of Linux right now to check if it has printf also.

# X title stuff
        wt ()
        {
                echo "^[]2;${@}^G\c"
        }
        it ()
        {
                echo "^[]0;${@}^G\c"
        }
        defwt ()
        {
                echo "^[]2;$(whoami) @ $(hostname)^G"
        }
        cls ()
        {
          # works only for vt100's and the like
               echo "^[[;H^[[2J"
        }

In Real Life, I have yet another function that dynamically modifies my window title to show me my current directory, but that will cost you extra.

Oh, ok... this works on bash but my older version worked on ksh. You would have to figure out how to get it to work with ksh. Better to switch to bash, IMHO. :rolleyes:

PROMPT_COMMAND=pc
titlebar="$myhostname ::: $myname   "
tprompt="[$myname@$myhostname]"
        if [ "$TERM" != "void" -a "$TERM" != "dumb" ] ; then
                bold=`tput bold`
                normal=`tput rmso`
                PROMPT_COMMAND=pc
                #PS1="\!\\[$bold\\]\`promptlen\`\\[$normal\\]\\$ "
        fi
function pc
        {
                pc_wd=`pwd`
                if [ \( "$TERM" = "vt100" \) -o \( "$TERM" = "xterm" \) ] ; then
                        wt "$titlebar << `pwd` >>" > `tty`
                fi
                # go to a 2-line prompt if >38 chars in path...
                case "$pc_wd" in
                /)
                        pc_path="/" ; pc_suffix="\\$ "
                ;;
                $HOME)
                        pc_path="~" ; pc_suffix="\\$ "
                ;;
                ??????????????????????????????????????*)
                        pc_path=$pc_wd ; pc_suffix="\n\\$ "
                ;;
                *)
                        pc_path=$pc_wd ; pc_suffix="\\$ "
                ;;
                esac
                PS1="\!\\[$bold\\]${tprompt}${pc_path}\\[$normal\\]${pc_suffix}"
                return
        }

...bold and normal do not work under Linux here. This is from my Sun, sorry. I have a version that works on Linux and Solaris but it's at work and I'm not.
-Mike

Thanks for those additional options mschwage. Might have to incorporate some of those ideas.

For now, I'm using the ksh shell and was actually able to configure a PS1 command to get colors in my prompt and dynamically set the title bar based on working directory location.

Thanks again for all the help.