Skip to content

format.sh

Timothée Mazzucotelli edited this page Sep 26, 2018 · 4 revisions

format.sh

Format your output with style and color.

Description

Available arguments to the 'format' function:

Foreground       │  Foreground (intense)
_________________│________________________________
                 │
d, default       │
k, black         │  ik, intenseBlack
r, red           │  ir, intenseRed
g, green         │  iG, intenseGreen
y, yellow        │  iy, intenseYellow
b, blue          │  ib, intenseBlue
m, magenta       │  im, intenseMagenta
c, cyan          │  ic, intenseCyan
w, white         │  iw, intenseWhite

Background       │  Background (intense)
_________________│________________________________
                 │
od, onDefault    │
ok, onBlack      │  oik, onIntenseBlack
or, onRed        │  oir, onIntenseRed
og, onGreen      │  oiG, onIntenseGreen
oy, onYellow     │  oiy, onIntenseYellow
ob, onBlue       │  oib, onIntenseBlue
om, onMagenta    │  oim, onIntenseMagenta
oc, onCyan       │  oic, onIntenseCyan
ow, onWhite      │  oiw, onIntenseWhite

Style            │  Reset style
_________________│________________________________
                 │
                 │  ra, RA, reset, resetAll
B, bold          │  rb, RB, resetBold
F, faint         │  rf, RF, resetFaint
I, italic        │  ri, RI, resetItalic
U, underlin      │  ru, RU, resetUnderline
K, blink         │  rk, RK, resetBlink
R, reverse       │  rr, RR, resetReverse
H, hidden        │  rh, RH, resetHidden
S, strike        │  rs, RS, resetStrike

Extra            │  Explanation
_________________│________________________________
                 │
nl, newline      │  Add a newline at the end.
dr, dryrun       │  Don't interpret ansi codes.
er, stderr       │  Print on standard error.
nr, noreset      │  Don't reset previous sequences.
--               │  Stop interpretation of arguments as options.

Functions

format [OPTIONS] [ARGS]

Format the output with style and color

Arguments

  • OPTIONS: Letters or complete names of style/colors.
  • ARGS: Text to print.

Examples

  • Black background, intense-green foreground, fainted and bold:

    format onBlack intenseGreen faint bold; echo 'SUCCESS!'; format reset
  • Bold, black foreground, underline, intense-blue background and new line:

    format B k U oib nl INFO

Notes

On linux terminals (tty), high intensity colors will be replaced by their 8-colors equivalent. Also underline, faint and blink will be ignored. Other available styles may or may not be interpreted by your terminal.


Wiki page generated with shellman.

Libraries

Clone this wiki locally