Script Echo Color: echoc "@{oGw} Script @kEcho @rC@go@bl@co@yr "
(invoque as ScriptEchoColor or echoc)

Download Latest version

Project homepage at SourceForge

Other Projects

v1.14 tested under GoboLinux 012
v1.12 tested under Fedora Core 1


ScriptEchoColor simplifies Linux terminal text colorizing,
formatting and several steps of script coding
(see --help, --help-extended and "secexamples" for details).

Index:
Colors and Formats
Simplifies Script Coding
Output of option "--help"

Colors and Formats:

A simple sintax is used to access colors and formats.

This example will output "test" with a Blue background and a light white foreground.
    echoc "@{Bow}test"

This one will output "test" with the foreground in green.
    echoc "@gtest"

All Colors/Formats:
Colors ScreenShot



Simplifies Script Coding (and echoes colored/formatted commands):

1) Wait for a key press:
    echoc -w
    echoc -w "When you ready"

2) Ask a question and receive an \"yes/no\" answear:
    if echoc -q "Ready to continue"; then
        echo "Hello"
    fi

3) Ask a question and receive a string answear:
    strName=`echoc -S "Type your Name"`
or a timed wait with default answear:
    strName=`echoc -St 5 "Type your Name@Dnoname"`
    echoc "@u$strName"

4) Execute a command:
    if echoc -x "pwd"; then
        echo "Ok"
    else
        echo "Error"
    fi



5) Append unformatted text to a log file:
    rm -f mylogfile.txt
    echoc -l mylogfile.txt "@G working... "
or
    SEC_LOG_FILE="mylogfile.txt"; export SEC_LOG_FILE
    echoc -L "@{LGob} Executing commands: "
    echoc -xL "ps -p $$"
    echoc -x "cat mylogfile.txt"
    SEC_LOG_FILE=""
or with automatic log file name creation
    rm -f `echoc --logfilename`
    echoc -Lq "@Bquestion mode logs question and answer"
    echoc -x "cat "`echoc --logfilename`



6) Change the environment with commands:
    strPwd=`pwd`
    pwd
    `echoc -v "cd .."`
    pwd
    eval `echoc -v "cd \"$strPwd\""`
    pwd
    strName2=""
    eval "`echoc -v 'strName2="'"$strName"'"'`"
    echoc "@u$strName2"

7) Show problem message (and sound a beep):
    nValue=10
    echoc -p "invalid value [$nValue]"
or '-pm' to mute the default beep to option -p



homepageexamples.sh



The output of option "--help":
(use option "--help-extended" for details)

ScriptEchoColor version 1.10
usage: ScriptEchoColor [-<c|x|X|v|V|q|Q|S|w|p><pmORbrktulLiI>] [-enE] ["string"]
 
 --help: a short help
 --help=list-escape: echo escape functionalities
 --help=list-gfx-mostreliable: common? chars between most terminal types
 --help=list-gfx-tputmacs: all macs chars
 --help=list-gfx-E294char: all escaped \xE2\x94\xHEXA chars
 --help=list-extended-format: extended format list
 --help-extended: extended help/usage information and examples!
 --test: test terminal capabilities and helps to bug report
 --parentpidlist: show a list of the parent pids (parent of parent of...)
 --guesstermemulator: show the parent executable name guessed as terminal emulator that is running ScriptEchoColor
 --version: show just "ScriptEchoColor 1.10" then exits
 --idea <Index>: executes one of the available usage ideas
 --logfilename: show the log file name being used (also automatic one)
 --gfx-mostreliable: (it is the default) use most realiable gfx chars trans. table
 --gfx-tputmacs: use tput smacs/rmacs gfx chars mode
 --gfx-E294char: use full gfx translation table
 --recreateconfigfile: will remove $HOME/.ScriptEchoColor/User.cfg to be recreated with defaults
 
Main options:
 -c: show caller
 -x: execute string as command line
 -X: execute string as command line and kill ParentPID on error (BEWARE)
 -v: echo and help change environment (see --help-extended) ex.: "cd .."
 -V: echo and help change environment, with exit command BEWARE (see --help-extended)
 -q: question mode
 -Q: extra question mode
 -S: question mode where you can type a String
 -w: wait mode
 -p: problem mode
 (do not use toguether, but auto choice precedence is: cpqQSwxXvV)
 
Options that can be combined with main options:
 -p: problem mode, can only be combined with main options -q or -w
 -n -e -E: bash echo options, see 'help echo'
 -m: Mute beep
 -O: ensure output to /dev/stdout
 -R: send output to /dev/stderr
 -b: Beep (see also SEC_BEEP)
 -r: reset previous settings
 -k: keep settings after end (color settings and position)
 -t <value>: time to wait before continuing
 -u: output Unformatted
 -l <logfile>: append unformatted text to logfile file
 -L: append unformatted text to logfile file at SEC_LOG_FILE (or default)
 -i: trap SIGINT
 -I: trap SIGINT and kill ParentPID (BEWARE)
 --: arguments after this are taken as normal text
 
String format summary (@/@{}):
 @{:}     "graphics" mode
 @{asAS}  save RESTORE settings
 @{0123456789.0123456789} absolute terminal position @{column.line}
 @{rgbcmykwRGBCMYKW}      foreground BACKGROUND colors
 @{oudnelL} bold/underline/dim/blink/strike/light/BACKGROUNDLIGHT types
 @{-f-b-l-L-o-u-d-n-e-t-:-a} cancel modes
 @{--} begin ignoring all formatting
 @++ (must be used this way: '@++') end ignoring all formatting
 @{+p} restore backup position
 @{/.../...} extended formatting (see the list with option --help=list-extended-format), must come as the end of commands within @{}
 
Observation: the default is to interpret escape characters, to disable it use -E


Documentation released under GPL licence.
Copyright (C) 2005 by Henrique Abdalla <
teike@users.sourceforge.net>

Hosted by SourceForge.net Logo