Sponsored Content
Full Discussion: color in bash
Top Forums Shell Programming and Scripting color in bash Post 302616905 by complex.invoke on Sunday 1st of April 2012 09:52:46 PM
Old 04-01-2012
A full featured color script!
Code:
#!/bin/bash

[[ x${1// /} == x || ${#1} > 3 ]] && T=gYw || T=${1}

esc="\e"
reset="${esc}[0m"

echo
echo -n "            "
echo -n 4{0..7}m | sed 's# #    #g' 
echo -n "   "
echo -n 1\;4{0..7}m | sed 's# #  #g'
echo -n "   0m    "
echo {1..8}m | sed 's# #   #g'

for FG in 3{0..7} 1\;3{0..7}; do
     for((i=0; i<5-${#FG}; ++i)); do
           echo -n " "
     done
     echo -en "${FG}${esc}[${FG}m ${T} "
     i=0
     for BG in 4{0..7} 1\;4{0..7} {0..8}; do
         (( i > 16 )) && {
         echo -en "${esc}[${FG};${BG}m ${T} ${reset}"
         } || echo -en "${esc}[${FG};${BG}m  ${T}  ${reset}"
         ((++i))
     done
     echo
done
echo


Last edited by complex.invoke; 04-01-2012 at 11:11 PM..
 

4 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to get rid of all the weird characters and color on bash shell

Does anyone of you know how to turn off color and weird characters on bash shell when using the command "script"? Everytime users on my server used that command to record their script, they either couldn't print it because lp kept giving the "unknown format character" messages or the print paper... (1 Reply)
Discussion started by: Micz
1 Replies

2. Shell Programming and Scripting

bash: color strings in log file

hello im looking for an easy way to color specific strings in text file. simple example: cat file1 acb 1234 qwer 5678 my goal: cat file1 (color the acb red and the 5678 blue) acb 1234 qwer 5678 cheers (2 Replies)
Discussion started by: modcan
2 Replies

3. OS X (Apple)

Adding Color to bash

Hey everyone, I have come across an issue to where I am trying to create a script which changes the text color with a simple if then statement. I have seen it done with Fedora 8 but when I try and create it using my MacBook Pro running Snow Leopard it doesn't work. Funny thing is, when I use... (2 Replies)
Discussion started by: dachadster13
2 Replies

4. Shell Programming and Scripting

Bash - changing a color of a substring

Hello! I need to write a bash script for my university classes, and I came up with an idea of a program that would test the speed of typing - there is some random text that you have to rewrite, and the script measures time, number of mistakes etc. The text would be visible on the screen all... (3 Replies)
Discussion started by: xqwzts
3 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 10:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy