s i s t e m a o p e r a c i o n a l m a g n u x l i n u x | ~/ · documentação · suporte · sobre |
Next
Previous
Contents
3. Dynamic titlesMany people find it useful to set the title of a terminal to reflect dynamic information, such as the name of the host the user is logged into, the current working directory, etc.
3.1 xterm escape sequencesWindow and icon titles may be changed in a running xterm by using XTerm escape sequences. The following sequences are useful in this respect:
ESC is the escape character (\033), and BEL is
the bell character (\007).
Printing one of these sequences within the xterm will cause the window or icon title to be changed.
Note: these sequences apply to most xterm derivatives,
such as
3.2 Printing the escape sequencesFor information that is constant throughout the lifetime of this shell, such as host and username, it will suffice to simply echo the escape string in the shell rc file:
should produce a title like username@hostname , assuming
the shell variables $USER and $HOST are set correctly.
The required options for echo may vary by shell (see examples
below).
For information that may change during the shell's lifetime, such as current working directory, these escapes really need to be applied every time the prompt changes. This way the string is updated with every command you issue and can keep track of information such as current working directory, username, hostname, etc. Some shells provide special functions for this purpose, some don't and we have to insert the title sequences directly into the prompt string. This is illustrated in the next section.
Next Previous Contents |