7.8 Highlighting in Shell PromptsIf your prompt has some information that you want to stand out - or if you want your whole prompt to stand out from the rest of the text on the screen - you might be able to make it in enhanced characters. If your terminal has special escape sequences (5.8 ) for enhancing the characters (and most do), you can use them to make part or all of your prompt stand out.
That prompt might look like this, with the word root@sys.ora.com#
The prompt is set inside double quotes (
Because the same escape sequences won't work on all terminals, it's probably a
good idea to add
an if
test (47.3
)
that only sets the prompt if the terminal type
$TERM
is in the Digital Equipment Corporation VT100 series (or one that
emulates it).
Table 7.1
shows a few escape sequences for VT100 and compatible terminals.
The
Of course, you can use different escape sequences if your terminal needs them. Better, read your terminal's terminfo or termcap database with a program like tput or tcap (41.10 ) to get the correct escape sequences for your terminal. Store the escape sequences in shell variables (6.8 ) .
bash
interprets octal character strings in the prompt.
So you can simplify the two commands above into the version below.
Change the backquotes ( PS1="\033[5mroot\033[0m@`uname -n`# "
Eight-bit-clean versions of tcsh
can put standout, boldface, and
underline - and any other terminal escape sequence, too - into your
shell prompt. For instance, For example, to make the same prompt as above with the word
set prompt = '%Sroot%s@%m# ' - |
|