Blog/Colors in bash

From ~esantoro
Revision as of 21:51, 25 April 2023 by Esantoro (talk | contribs) (Created page with "These are a few lines of code to get some basic coloring when writing bash scripts. I'm publishing them here because sometimes i have to use <s>work</s> other people's computers and it comes handy to be able to copy-and-paste them where needed. <syntaxhighlight lang="bash"> function yellow { tput setaf 3 ; echo $1 ; tput sgr0 } function red { tput setaf 1 ; echo $1 ; tput sgr0 } function green { tput setaf 2 ; echo $1 ; tput sgr0 } function cyan { tp...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

These are a few lines of code to get some basic coloring when writing bash scripts.

I'm publishing them here because sometimes i have to use work other people's computers and it comes handy to be able to copy-and-paste them where needed.

function yellow {
    tput setaf 3 ; echo $1 ; tput sgr0
}

function red {
    tput setaf 1 ; echo $1 ; tput sgr0
}

function green {
    tput setaf 2 ; echo $1 ; tput sgr0
}

function cyan {
    tput setaf 6 ; echo $1 ; tput sgr0
}