|
Home > Archive > Unix Shell > January 2006 > Underlined Header
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| contracer11@gmail.com 2006-01-29, 9:31 pm |
| Hi Unix Masters:
I=B4m using this command line to create a header in blue color:
echo '\033[36;44m - NetBackup - Active Jobs -
\033[m'
Which command could I use to create an underlined header ?
Thanks !
| |
| Bill Marcum 2006-01-29, 9:31 pm |
| On 29 Jan 2006 03:25:10 -0800, contracer11@gmail.com
<contracer11@gmail.com> wrote:
> Hi Unix Masters:
>
> I´m using this command line to create a header in blue color:
>
> echo '\033[36;44m - NetBackup - Active Jobs -
> \033[m'
>
> Which command could I use to create an underlined header ?
>
If your terminal supports underlining:
printf "%20s%s" " " "$(tput smul)$(tput setaf 4)"
printf "%s" "- NetBackup - Active Jobs -"
printf "%s\n" "$(tput setaf 0)$(tput rmul)"
See "man 5 terminfo" for arguments to the tput command.
--
If there are self-made purgatories, then we all have to live in them.
-- Spock, "This Side of Paradise", stardate 3417.7
| |
| Michael Paoli 2006-01-29, 9:31 pm |
| contracer11@gmail.com wrote:
> I'm using this command line to create a header in blue color:
> echo '\033[36;44m - NetBackup - Active Jobs -
> \033[m'
> Which command could I use to create an underlined header ?
Read and learn about terminfo, tput, ncurses, etc. (and also of
interest historically and/or for more backwards compatibility,
termcap).
One of the problems UNIX solves quite well, is how do we handle
dealing with hundreds or more, different types of terminals (and/or
emulations thereof), and all the different control codes and escape
sequences needed to use features we'd typically want to utilize (e.g.
how do we clear the screen, how do we position the cursor, etc.).
For this, UNIX provides terminfo and related, which provides a
database of terminal types, capabilities, and the codes needed to
utilize those capabilities, and the commands, libraries, to test for
and use capabilities, etc. Without such an abstraction layer of
terminal capabilities, every single program that would need to
utilize specific capabilities, would need to know how to handle the
specific type of terminal it's dealing with - quite a mess to
maintain with hundreds or more possible terminal types. With the
terminfo, etc. abstraction layer, the information on supported
terminals their capabilities and how to utilize their capabilities,
is maintained in an organized and centralized manner. This makes
adding support of a new or different terminal type quite easy, and
also makes writing programs that support a large variety of terminal
types, and are easily updated to handle new types of terminals, quite
a manageable task.
Also, you may want to avoid not only hard coding specific
control/escape sequences, but also avoid hard coding specific color
settings, etc. It may be advisable to have some kind of
configuration file with particular use and color assigned, so that it
could be changed if a different theme is later desired (to suit
personal preferences, or better work with color blindness, etc.),
$ find /usr/share/terminfo -follow -type f -print | wc -l
2498
^^^^ Lots of terminal types and emulations/variations thereof
examples*:
#!/bin/sh
a_black=0
a_red=1
a_green=2
a_yellow=3
a_blue=4
a_magenta=5
a_cyan=6
a_white=7
a_background=$a_white
a_active_color_foreground=$a_blue
tput smul
echo -n underline
tput rmul
echo ''
tput setaf $a_active_color_foreground
tput setab $a_background
echo -n ACTIVE
tput sgr0
echo ''
references:
terminfo(5)
tput(1)
tic(1)
infocmp(1)
captoinfo(1)
infotocap(1)
toe(1)
ncurses(3NCURSES)
termcap(3NCURSES)
term(5)
*primarily for illustrative purposes, not endorsed or recommended
for general use as-is, see also:
http://www.rawbw.com/~mp/unix/sh/#G...mming_Practices
| |
| grulos 2006-01-29, 9:31 pm |
| contracer11@gmail.com wrote:
> Which command could I use to create an underlined header ?
I'm not sure if this is what you want.
echo -e "\033[4;44m - NetBackup - Active Jobs -\033[m"
--
http://grulos.blogspot.com/
|
|
|
|
|