Operating System - Linux
1820389 Members
3588 Online
109623 Solutions
New Discussion юеВ

BOLD LETTERS FOR SHELL SCRIPT

 
SOLVED
Go to solution
Muguerza
Occasional Contributor

BOLD LETTERS FOR SHELL SCRIPT

I need to make a bold message
PS3=:"
(bold)INTRODUCE EL NUMERO DE OPCION:"
Any example for make a shell script for present messages in bold for shell script my shell is
PS3="
INTRODUCE EL NUMERO DE OPCION:"
select clean_menu in "BAJAR BASE DE DATOS" "SUBIR BASE DE DATOS" "SALIR"
do
case $clean_menu in
"BAJAR BASE DE DATOS")
/oradb/ora_stop_db_DGCHM.sh;;

"SUBIR BASE DE DATOS")
/oradb/ora_start_db_DGCHM.sh;;

"SALIR") break ;;
esac
done
11 REPLIES 11
Pete Randall
Outstanding Contributor
Solution

Re: BOLD LETTERS FOR SHELL SCRIPT

Blatantly borrowed from Bill Hassell:

export HB=$(tput dim 2>/dev/null) # dim text
export HV=$(tput smso 2>/dev/null) # 1/2 bright inverse
export IV=$(tput bold 2>/dev/null) # inverse
export UL=$(tput smul 2>/dev/null) # underline
export BL=$(tput blink 2>/dev/null) # blink
export EL=$(tput el 2>/dev/null) # clear to end of line
export ED=$(tput ed 2>/dev/null) # clear to end of display
export EE=$(tput sgr0 2>/dev/null) # end all enhancements
echo "normal $HV smso $HB dim $IV bold $UL smul $BL blink $EE normal"


Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: BOLD LETTERS FOR SHELL SCRIPT

BOLD=$(tput bold)
NORM=$(tput sgr0)

echo "${BOLD}\c"
This should be bold.
echo "${NORM}\c"
This should be normal


Not all terminals support bold so you should probably use BOLD=(tput smso) nad NORM=(tput rmso)" instead but you could test it see if bold is available using the tput command. Man tput , terminfo for details.
If it ain't broke, I can fix that.
Muguerza
Occasional Contributor

Re: BOLD LETTERS FOR SHELL SCRIPT

Exist any option for brightnes
A. Clay Stephenson
Acclaimed Contributor

Re: BOLD LETTERS FOR SHELL SCRIPT

It depends upon the particular terminal type.
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: BOLD LETTERS FOR SHELL SCRIPT

Hi:

> Exist any option for brightnes

As Clay notes, everything depends upon your terminal type. If you look at the 'terminfo(4)' and 'tput(1)' manpages, you will find that "bold" is considered equivalant to "extra-bright".

Regards!

...JRF...
Muguerza
Occasional Contributor

Re: BOLD LETTERS FOR SHELL SCRIPT

Thanks Gurus

My question is what is the option for the cursor display and not display




A. Clay Stephenson
Acclaimed Contributor

Re: BOLD LETTERS FOR SHELL SCRIPT

The answer is still "man terminfo". ... and it still depends upon the TERM type whether or not this is possible.
If it ain't broke, I can fix that.
Bill Hassell
Honored Contributor

Re: BOLD LETTERS FOR SHELL SCRIPT

Attached is ttyenhance, a simple script to show the most common video enhancements available on the current terminal emulator (hardly anyone has a real terminal these days). As mentioned, the terminfo man page (one of the longest in all of HP-UX -- trivia: gated.conf is the longest) is extensive and defines a generic way to access the multitude of terminal features from literally hundreds of different models. All of this works when you don't lie about your terminal -- which means TERM=vt100 is never allowed, you must have ttytype set your TERM and related values, like this in .profile or /etc/profile:

eval $(ttytype -sa)

ttyenhance graphically shows the video features but is just using the Curses library to figure out what codes or escape sequences are needed for this terminal. Related to ttytype are the untic and tpu commands. untic shows (in terminfo talk) whether a feature exists and if so, shows to activate each feature.


Bill Hassell, sysadmin
OldSchool
Honored Contributor

Re: BOLD LETTERS FOR SHELL SCRIPT

Bill,

Looks like the attachment didn't
Bill Hassell
Honored Contributor

Re: BOLD LETTERS FOR SHELL SCRIPT

You're right!! Must be something wrong with my mouse. ;-)

Here's the attachment.


Bill Hassell, sysadmin
Bill Hassell
Honored Contributor

Re: BOLD LETTERS FOR SHELL SCRIPT

OK, attachments are broken again...here's the code:

#!/usr/bin/sh
# Bill Hassell Jun 2004

# Script to display terminal characteristics using Curses

# usage: ttyenhance [ any text will turn off ttytype polling ]
# Run with any text to bypass the ttytype polling and use
# the current value of $TERM, $LINES and $COLUMNS


set -u
PATH=/usr/bin

if [ $# -gt 0 ]
then
echo
echo "Current settings: TERM=$TERM, LINES=$LINES, COLUMNS=$COLUMNS"
else
eval $(ttytype -s)
echo
echo "ttytype says this terminal is a $TERM, LINES=$LINES, COLUMNS=$COLUMNS"
fi

# see if there is a terminal like this defined

tput sgr0 > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "$TERM is unknown to the terminfo database on this computer"
exit
fi

HB=$(tput dim) # dim text
HV=$(tput smso) # 1/2 bright inverse
IV=$(tput bold) # inverse
UL=$(tput smul) # underline
BL=$(tput blink) # blink
EE=$(tput sgr0) # end enhancements

echo
echo "Typical names:"
echo "\t$EE Normal $IV Inverse $EE $HB Dim $EE $BL Blink $EE $HV halfbrite $EE $UL underline $EE"

echo
echo "Curses capname (tput)"
echo "\t$EE SGR0 $IV BOLD $EE $HB DIM $EE $BL BLINK $EE $HV SMSO $EE $UL SMUL $EE"
echo


Bill Hassell, sysadmin