Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Overriding colors? #197

Open
luanalatte opened this issue Jun 23, 2022 · 1 comment
Open

Overriding colors? #197

luanalatte opened this issue Jun 23, 2022 · 1 comment

Comments

@luanalatte
Copy link

I wanted to override the colors used in pfetch with truecolor escape sequences. I tried doing so while not modifying pfetch's code so I used PF_SOURCE but the palette was being set AFTER sourcing my script.

One option is to move the sourcing of the script to after the colors have been set.

Another one is to add a check and skip setting colors that are already set:

for _c in c1 c2 c3 c4 c5 c6 c7 c8; do
    [ -z "${!_c}" ] || continue
    esc SGR "3${_c#?}" 0
    export "$_c=$e"
done

However I am not sure if ${!_c} is POSIX sh. Also, it's possible there's a better way to do it.

It works with this on my PF_SOURCE script:

c4="${esc_c}[38;2;255;0;0m"

Although it also needs this change to https://github.com/dylanaraps/pfetch/blob/master/pfetch#L1827 so that it doesn't count the extra characters in the escape sequence:

$(printf %s "$ascii" | sed 's/�\[3.*m//g')
@luanalatte
Copy link
Author

The regex is wrong. It will count everything until the last m it finds, I think.
I fixed it by using

's/�\[[0-9;]*m//g'

Escape codes can use only numbers and semicolons, right? I think some other symbols can be used but those could be easily added into the regex, or someone with a little bit more knowledge could make it count only until the first 'm' it finds.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant