The
sequence is:
ESC ] 0 ; text BEL
where ESC and BEL are the corresponding ASCII codes (27 and 7 in decimal, 033
and 007 in octal, 0x21 and 0x7 in hexadecimal), and text is the text that should be
presented in the title bar. Therefore, to set the title to My Window, you could execute
the following:
$ echo -e "\033]0;My Window\007\c"
When using bash, you can set the PROMPT_COMMAND environment variable to a command
that should be executed before each prompt is printed. This is often set to
show useful information, such as the current directory, using a command such as
this:
$ export PROMPT_COMMAND='echo -e "\033]0;${PWD}\007\c"'
You can also set the title bar in the prompt:
$ export PS1="\e]0;\$USER@\$HOST: \$PWD\a$ "
If you??™re using csh, the cwdcmd, precmd, and postcmd aliases enable you to execute a
command after each directory change, before each prompt is printed, or after each
command is entered, respectively. To update the window title to the current directory
after each directory change:
% alias cwdcmd 'echo -n "^[]0;$cwd^G"'
To enter the ^[ in this line, press Ctrl-V, ESC; to enter ^G, press Ctrl-V, Ctrl-G. Or, if
you??™re using tcsh and have echo_style set to both, you can type \e in place of ^[ and
\a in place of ^G.
Pages:
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200