Search code examples
regexsedterminalescapingansi-escape

How do i get rid of these escape characters. Looking for some sort of regex


I am trying to output the output of neofetch to a discord embed for a project of mine. Is there any easy way to get rid of that escape sequence at the start and end of the embed.

the command i used to generate the output is neofetch --off --color_blocks off | sed 's/\x1b\[[0-9;]*[a-zA-Z]//g'

enter image description here


Solution

  • Those escape sequences are color codes.

    You can use the --stdout option to disable all coloring:

    neofetch --off --color_blocks off --stdout
    

    See neofetch --help:

    OTHER:
    ...
    --stdout Turn off all colors and disables any ASCII/image backend.