help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing colouring through a line of text


From: Bipul kumar
Subject: Re: Changing colouring through a line of text
Date: Thu, 23 Mar 2023 23:37:38 +0530

*if u want to colorize lots of already existing output ( not generating ..
) i suggest g/awk*
Based on my understanding, it seems that the issue you've presented
regarding text coloring can be addressed using higher-level programming
languages that are not limited to bash or awk, and this is my perception of
the matter.

    Respectfully,
    Bipul
    PUBLIC KEY <http://ix.io/1nWf>
    97F0 2E08 7DE7 D538 BDFA  B708 86D8 BE27 8196 D466
                    ** Please excuse brevity and typos. **


On Wed, Mar 22, 2023 at 1:36 PM alex xmb ratchev <fxmbsw7@gmail.com> wrote:

>
>
> On Wed, Mar 22, 2023, 08:17 alex xmb ratchev <fxmbsw7@gmail.com> wrote:
>
>>
>>
>> On Wed, Mar 22, 2023, 05:16 Bipul kumar <bipul.opensource@gmail.com>
>> wrote:
>>
>>> Hi,
>>> I apologize for my mistake in sending you the wrong image earlier.
>>> Things have been a bit hectic here, but I have set aside two hours to
>>> address your concerns and debug the code.
>>> Please find the  correct code and I hope that it will resolve your issue.
>>>
>>> >
>>> > marinex-ndic ()  {
>>> > local -r rst="$( tput sgr0 )"  # Default Graphic Rendition
>>> > local -r blu="$( tput bold; tput setaf 39 )"  # BLUE
>>> > local -r wht="$( tput bold; tput setaf 15 )"  # WHITE
>>> > printf '%s\n' "$2"      | while IFS="" read -r vl
>>> > do
>>> > printf '%s%s%s%s%s\n' "${blu}" "$(echo $vl | cut -c 1-$1)" "${wht}"
>>> > "$(echo $vl | cut -c $(($1+1))-)" "${rst}"
>>> > done
>>> > }
>>>
>>
>> code without $( .. )
>>
>
> if u want to colorize lots of already existing output ( not generating ..
> ) i suggest g/awk
>
> IFS=$' \t\n' \
>> b=$( tput bold ; tput setaf 39 ) r=$( tput sgr0 )
>>
>>  mark() {
>> till=$1 flat=${*: 2}
>> printf "$r$b%s$r%s\\n" "${flat: :till}" "${flat: till}"
>>  }
>>
>> mark 3 123456
>>
>> Apart, I would suggest that you should add some error handling into this
>>> script to prevent any further mishaps.
>>> Thank you for your understanding.
>>>
>>>     Respectfully,
>>>     Bipul
>>>     PUBLIC KEY <http://ix.io/1nWf>
>>>     97F0 2E08 7DE7 D538 BDFA  B708 86D8 BE27 8196 D466
>>>                     ** Please excuse brevity and typos. **
>>>
>>>
>>> On Wed, Mar 22, 2023 at 12:43 AM uzibalqa <uzibalqa@proton.me> wrote:
>>>
>>> >
>>> >
>>> > ------- Original Message -------
>>> > On Wednesday, March 22nd, 2023 at 2:52 AM, Bipul kumar <
>>> > bipul.opensource@gmail.com> wrote:
>>> >
>>> >
>>> > > sorry the wrong image has been sent out mistakenlyPlease find the
>>> > correct one
>>> > >
>>> > > [Client-looking.png]
>>> > >
>>> > > Hope it works to your end.
>>> > >
>>> > > Respectfully,
>>> > > Bipul
>>> > > PUBLIC KEY
>>> > > 97F0 2E08 7DE7 D538 BDFA B708 86D8 BE27 8196 D466
>>> > > ** Please excuse brevity and typos. **
>>> > >
>>> > > On Tue, Mar 21, 2023 at 8:19 PM Bipul kumar <
>>> bipul.opensource@gmail.com>
>>> > wrote:
>>> > >
>>> > > > Hi
>>> > > > If I understand correctly, you want to enter two things: a number
>>> > indicating the number of columns you want, and a string.
>>> > > > You want to print the beginning of the string up to the specified
>>> > number of columns in blue and the rest of the string in white.
>>> > > >
>>> > > > At this point of your code ** printf '%s%s%s%s%s\n' "${blu}" "$vl"
>>> > "$wht" "$vl" "${rst}" **
>>> > > > you should modify your code to retrieve output by utilizing the
>>> > specified range mentioned in the 1st argument (i.e., 18 in your
>>> case).Then,
>>> > you need to print it using the reference of shell variables (e.g.,
>>> blue and
>>> > white) that you defined earlier in your code for foreground.
>>> > > >
>>> > > > For example here in this picture
>>> > > > https: // ibb.co/0CQbXgc
>>> > > > https://ibb.co/0CQbXgc
>>> > > > [faceoff.jpeg]
>>> > > > To retrieve the desired string for the blue and white outputs, I
>>> have
>>> > used the cut command in a subshell.
>>> > > > This command is applied to the input string provided as the second
>>> > argument to the function.
>>> > > >
>>> > > >
>>> > > > Respectfully,
>>> > > > Bipul
>>> > > > PUBLIC KEY
>>> > > > 97F0 2E08 7DE7 D538 BDFA B708 86D8 BE27 8196 D466
>>> > > > ** Please excuse brevity and typos. **
>>> > > >
>>> > > > On Mon, Mar 20, 2023 at 8:58 PM uzibalqa <uzibalqa@proton.me>
>>> wrote:
>>> > > >
>>> > > > > I am doing a bash function that takes a multiline string and
>>> prints
>>> > each line. The first part of each line uses a blue foreground, whereas
>>> the
>>> > rest of each line uses a white foreground.
>>> > > > >
>>> > > > > I want to have the user define a column number from which the
>>> > foreground colour on each line changes to white.
>>> > > > >
>>> > > > > I need help to do this.
>>> > > > >
>>> > > > > The input string would be
>>> > > > >
>>> > > > > str='
>>> > > > > marinex-dgrul Digit
>>> > > > > marinex-ltrul Letter
>>> > > > > marinex-nmrul Numeric'
>>> > > > >
>>> > > > > Then one would call
>>> > > > >
>>> > > > > marinex-ndic 18 "$str"
>>> > > > >
>>> > > > > The plan is to have the beginning of each line being blue, whilst
>>> > from column number 18 the colour changes to white.
>>> > > > >
>>> > > > > marinex-ndic ()
>>> > > > > {
>>> > > > > ## Show coloured and label
>>> > > > >
>>> > > > > local -r rst="$( tput sgr0 )" # Default Graphic Rendition
>>> > > > > local -r blu="$( tput bold; tput setaf 39 )" # BLUE
>>> > > > > local -r wht="$( tput bold; tput setaf 15 )" # WHITE
>>> > > > >
>>> > > > > printf '%s\n' "$@" \
>>> > > > > | while IFS="" read -r vl; do
>>> > > > > printf '%s%s%s%s%s\n' "${blu}" "$vl" "$wht" "$vl" "${rst}"
>>> > > > > done
>>> > > > > }
>>> >
>>> > Thought it was a joke.
>>>
>>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]