Graphics Q & A's for Terminals


1. How do I change the title of an aixterm dynamically?
2. How do I change the title of the (ai)xterm to the working directory that I am in?
3. How do I change the number of lines in a window's scrollback buffer?
4. How do I change the width of the dtterm scrollbar?
5. How do I set environment variables for a specific terminal window?
6. How do I set the environment for the terminal window as it is launched?

1. How do I change the title of an aixterm dynamically?

The following script will work with aix/dt/xterm.

	#!/bin/ksh
echo "\033]0;$1\007"

To run, enter the following:

	chtitle <Message>

To change the title of the aixterm dynamically, enter the following at the command line.

	echo "^[]#;name"

Where # is:

0 - will print both the window name and title when iconified.

1 - will print the title on the icon but leave the window title intact.

2 - will print the window name without the title name changing when iconified.


2. How do I change the title of the (ai)xterm to the working directory that I am in?

NOTE:The following instructions are written for the Korn shell (ksh).

Change the line in /usr/dt/bin/Xsession from:

	TERM=dtterm to TERM=none
Now, insert the following in your .kshrc
	if [ ${SHELL##/*/} = "ksh" ] ; then
	if [[ $TERM = *"term" ]] ; then
	export PS1="C:/>"
	HOSTNAME=`uname -n`
	label () { echo "\\033]0;$*\\007\\c"; }
	alias stripe='label `whoami` on $HOSTNAME - $PWD'
	cds () { "cd" $*; eval stripe; }
	tns () { "tn" $*; eval stripe; }
	rl () { "rlogin" $*; eval stripe; }
	alias cd=cds
	alias tn=tns
	fi
        fi

You can change the alias stripe line to read:

	alias stripe='label $LOGNAME on $HOSTNAME - ${PWD#$HOME/}'

This will display only the name of the directory (not the fully qualified path), you are currently in if it is within your home directory. If you are in a directory that is not a subdirectory of your $HOME, it will display the fully qualified path.

	if ( $TERM == aixterm ) then
	set prompt="[%~] %n@%m % "
        alias cwdcmd 'echo -n "^[]2;`whoami` on ${HOST} - $cwd^G^[]1;${HOST}^G"'
	alias vi 'echo -n "^[]2;${HOST} - editing file-> \!*^G" ; /usr/bin/vi \!* ; cwdcmd'
	alias telnet '/bin/telnet \!* ; cwdcmd'
	alias rlogin '/usr/bin/rlogin \!* ; cwdcmd'
	cwdcmd
	else
	set prompt="[%~] %n@%m % "
	endif

This adds Editing <filename> to the titlebar whenever you are using vi to edit a file.


3. How do I change the number of lines in a window's scrollback buffer?

The number of lines is controlled by the saveLines resource. You can use this in the user's .Xdefaults, like the example below.

	aixterm*saveLines:	<number_of_lines>
or
	aixterm -sl -sb 500

4. How do I change the width of the dtterm scrollbar?

Run the following command from the command line to change the width of the scrollbar of the dtterm.

	dtterm -xrm "*dtTermScrollBar.width: 5"

Or, you can make an entry in $HOME/.Xdefaults that reads:

	Dtterm*dtTermScrollBar*width: 5

5. How do I set environment variables for a specific terminal window?

Place the following script in .kshrc.

	if [ $TERM = dtterm ]
	then
	export MYVAR=myvalue
	export MYVAR2=myvalue2
	fi

The preceding script will set the two variables for any dtterm which is opened.


6. How do I set the environment for the terminal window as it is launched?

Add the following line to .profile:

	export SPECIAL_ENV=no
Add the following to .kshrc:
	if [ $SPECIAL_ENV = yes ]
	then
	export MYVAR=myvalue
	export MYVAR2=myvalue2
	fi
Create a shell script that looks like the following:
	#!/bin/ksh
	export SPECIAL_ENV=yes
	/usr/dt/bin/dtterm

When you would like to use a dtterm that has this special environment set, you will need to execute the script that you created above. You could have your shell script call any other terminal window.



[ Doc Ref: 97249760421358     Publish Date: Oct. 25, 2000     4FAX Ref: none ]