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

How to disable colors? #753

Closed
raxod502 opened this issue Jun 19, 2017 · 17 comments
Closed

How to disable colors? #753

raxod502 opened this issue Jun 19, 2017 · 17 comments

Comments

@raxod502
Copy link

Description

I would like to pipe the output of neofetch into another command, but cannot figure out how to disable the ASCII escape codes that litter the output. I did not see any options in man neofetch that appeared to be relevant.

Neofetch version

3.1.0

Config file

None

@ladislavskufca
Copy link

You mean "color bar"?

Open your configuration file in .config and use # to make comment and hide info cols. I think that this is the bar you want to hide.

@dylanaraps
Copy link
Owner

No, he means the escape codes that format the text.

Neofetch currently doesn't have an option to do this and I'm not sure if I'll add this feature since Neofetch wasn't intended to be piped into other commands. If you'd like to use some info from Neofetch I'd instead suggest looking into the source code to find the file or system command that displays the information you'd like to pipe.

@raxod502
Copy link
Author

The most frequent thing that I use Neofetch for is filling in the "System Information" section in an issue report. So I run neofetch and then copy/paste the output. But I would much prefer to just do neofetch | pbcopy!

@ghost
Copy link

ghost commented Jun 25, 2017 via email

@raxod502
Copy link
Author

Well, that would technically work, but it seems a little bit of an excessively hacky workaround to me. I could certainly put it in an alias, though. Thanks!

@raxod502
Copy link
Author

Actually, I take it back. Before, it looked like this:

�[?25l�[?7l�[0m�[32m�[1m                -/+:. 
               :++++. 
              /+++/. 
      .:-::- .+/:-``.::- 
   .:/++++++/::::/++++++/:` 
�[0m�[33m�[1m .:///////////////////////:` 
 ////////////////////////` 
�[0m�[31m�[1m-+++++++++++++++++++++++` 
/++++++++++++++++++++++/ 
�[0m�[31m�[1m/sssssssssssssssssssssss. 
:ssssssssssssssssssssssss- 
�[0m�[35m�[1m osssssssssssssssssssssssso/` 
 `syyyyyyyyyyyyyyyyyyyyyyyy+` 
�[0m�[34m�[1m  `ossssssssssssssssssssss/ 
    :ooooooooooooooooooo+. 
     `:+oo+/:-..-:/+o+/- 
�[16A�[9999999D�[32C�[0m�[1m�[32m�[1mraxod502�[0m@�[32m�[1mRadon-MBP-New.local�[0m 
�[32C�[0m----------------------------�[0m 
�[32C�[0m�[33m�[1mOS�[0m�[0m:�[0m OS X El Capitan 10.11.6 15G1510 x86_64�[0m 
�[32C�[0m�[33m�[1mModel�[0m�[0m:�[0m MacBookPro11,3�[0m 
�[32C�[0m�[33m�[1mKernel�[0m�[0m:�[0m 15.6.0�[0m 
�[32C�[0m�[33m�[1mUptime�[0m�[0m:�[0m 16 days, 14 hours, 45 minutes�[0m 
�[32C�[0m�[33m�[1mPackages�[0m�[0m:�[0m 340�[0m 
�[32C�[0m�[33m�[1mShell�[0m�[0m:�[0m zsh 5.3.1�[0m 
�[32C�[0m�[33m�[1mResolution�[0m�[0m:�[0m 3008x1692, 1440x900�[0m 
�[32C�[0m�[33m�[1mDE�[0m�[0m:�[0m Aqua�[0m 
�[32C�[0m�[33m�[1mWM�[0m�[0m:�[0m Quartz Compositor�[0m 
�[32C�[0m�[33m�[1mWM Theme�[0m�[0m:�[0m Blue�[0m 
�[32C�[0m�[33m�[1mTerminal�[0m�[0m:�[0m iTerm2�[0m 
�[32C�[0m�[33m�[1mTerminal Font�[0m�[0m:�[0m InputMono-Medium 14�[0m 
�[32C�[0m�[33m�[1mCPU�[0m�[0m:�[0m Intel i7-4980HQ (8) @ 2.80GHz�[0m 
�[32C�[0m�[33m�[1mGPU�[0m�[0m:�[0m Intel Iris Pro, NVIDIA GeForce GT 750M�[0m 
�[32C�[0m�[33m�[1mMemory�[0m�[0m:�[0m 5564MiB / 16384MiB�[0m 

�[32C�[0m�[30m�[40m   �[0m�[31m�[41m   �[0m�[32m�[42m   �[0m�[33m�[43m   �[0m�[34m�[44m   �[0m�[35m�[45m   �[0m�[36m�[46m   �[0m�[37m�[47m   �[0m


�[?25h�[?7h

Now, it looks like this:

�[?25l�[?7l                -/+:. 
               :++++. 
              /+++/. 
      .:-::- .+/:-``.::- 
   .:/++++++/::::/++++++/:` 
 .:///////////////////////:` 
 ////////////////////////` 
-+++++++++++++++++++++++` 
/++++++++++++++++++++++/ 
/sssssssssssssssssssssss. 
:ssssssssssssssssssssssss- 
 osssssssssssssssssssssssso/` 
 `syyyyyyyyyyyyyyyyyyyyyyyy+` 
  `ossssssssssssssssssssss/ 
    :ooooooooooooooooooo+. 
     `:+oo+/:-..-:/+o+/- 
�[16A�[9999999D�[32Craxod502@Radon-MBP-New.local 
�[32C---------------------------- 
�[32COS: OS X El Capitan 10.11.6 15G1510 x86_64 
�[32CModel: MacBookPro11,3 
�[32CKernel: 15.6.0 
�[32CUptime: 16 days, 14 hours, 44 minutes 
�[32CPackages: 340 
�[32CShell: zsh 5.3.1 
�[32CResolution: 3008x1692, 1440x900 
�[32CDE: Aqua 
�[32CWM: Quartz Compositor 
�[32CWM Theme: Blue 
�[32CTerminal: iTerm2 
�[32CTerminal Font: InputMono-Medium 14 
�[32CCPU: Intel i7-4980HQ (8) @ 2.80GHz 
�[32CGPU: Intel Iris Pro, NVIDIA GeForce GT 750M 
�[32CMemory: 5572MiB / 16384MiB 

�[32C                        


�[?25h�[?7h

So some of the escape codes are gone, but not all of them.

@ghost
Copy link

ghost commented Jun 25, 2017

Those sequences are not generated by neofetch:

color() {
    case "$1" in
        [0-6]) printf "%b" "${reset}\033[3${1}m" ;;
        7 | "fg") printf "%b" "\033[37m${reset}" ;;
        *) printf "%b" "\033[38;5;${1}m" ;;
    esac
}

Do you have a wrapper in there that uses ncurses? Looks alot like curses output to me.

Updated sed line would be like neofetch|sed 's/\x1B\[[0-9;\?]*[a-zA-Z]//g'

@dylanaraps
Copy link
Owner

dylanaraps commented Jun 25, 2017 via email

@ghost
Copy link

ghost commented Jun 25, 2017

Ah i see.

The updated sed line should work anyways.

@raxod502
Copy link
Author

raxod502 commented Jun 25, 2017

Judging by the output, it looks like things are no longer aligned, presumably since the alignment is done using escape codes. I can see how it would be difficult to add streaming support to Neofetch—but as a workaround, is there a way of running a command in a pseudo-tty and then copying the contents of the tty? That would really be what I want.

(But the sed command does work in stripping out the escape codes; thanks!)

                -/+:. 
               :++++. 
              /+++/. 
      .:-::- .+/:-``.::- 
   .:/++++++/::::/++++++/:` 
 .:///////////////////////:` 
 ////////////////////////` 
-+++++++++++++++++++++++` 
/++++++++++++++++++++++/ 
/sssssssssssssssssssssss. 
:ssssssssssssssssssssssss- 
 osssssssssssssssssssssssso/` 
 `syyyyyyyyyyyyyyyyyyyyyyyy+` 
  `ossssssssssssssssssssss/ 
    :ooooooooooooooooooo+. 
     `:+oo+/:-..-:/+o+/- 
raxod502@Radon-MBP-New.local 
---------------------------- 
OS: OS X El Capitan 10.11.6 15G1510 x86_64 
Model: MacBookPro11,3 
Kernel: 15.6.0 
Uptime: 16 days, 15 hours, 12 minutes 
Packages: 340 
Shell: zsh 5.3.1 
Resolution: 3008x1692, 1440x900 
DE: Aqua 
WM: Quartz Compositor 
WM Theme: Blue 
Terminal: iTerm2 
Terminal Font: InputMono-Medium 14 
CPU: Intel i7-4980HQ (8) @ 2.80GHz 
GPU: Intel Iris Pro, NVIDIA GeForce GT 750M 
Memory: 5970MiB / 16384MiB 

                        


@konimex
Copy link
Contributor

konimex commented Aug 3, 2017

You can now disable colors in stdout mode.

Run neofetch with --stdout flag enabled and you're good to go. The ASCII/Images will be disabled.

@konimex konimex closed this as completed Aug 3, 2017
@raxod502
Copy link
Author

raxod502 commented Aug 3, 2017

Nice! But there are still some escape codes at the bottom:

% neofetch --stdout | pbcopy

gives me

rrosborough@[redacted]
-----------------------------
OS: macOS Sierra 10.12.5 16F73 x86_64
Model: MacBookPro11,4
Kernel: 16.6.0
Uptime: 36 days, 1 hour, 35 mins
Packages: 225
Shell: zsh 5.3.1
Resolution: 1920x1200
DE: Aqua
WM: Kwm
Terminal: iTerm2
Terminal Font: InputMono-Medium 12
CPU: Intel i7-4980HQ (8) @ 2.80GHz
GPU: Intel Iris Pro
Memory: 4804MiB / 16384MiB

�[C�[30m�[40m   �[31m�[41m   �[32m�[42m   �[33m�[43m   �[34m�[44m   �[35m�[45m   �[36m�[46m   �[37m�[47m   

@ghost
Copy link

ghost commented Aug 3, 2017

Try this: neofetch --stdout --color_blocks off

@raxod502
Copy link
Author

raxod502 commented Aug 3, 2017

It works great, thanks.

rrosborough@[redacted]
-----------------------------
OS: macOS Sierra 10.12.5 16F73 x86_64
Model: MacBookPro11,4
Kernel: 16.6.0
Uptime: 36 days, 1 hour, 55 mins
Packages: 226
Shell: zsh 5.3.1
Resolution: 1920x1200
DE: Aqua
WM: Kwm
Terminal: iTerm2
Terminal Font: InputMono-Medium 12
CPU: Intel i7-4980HQ (8) @ 2.80GHz
GPU: Intel Iris Pro
Memory: 5019MiB / 16384MiB


I'm slightly bothered by the extra blank lines at the bottom, but I can live with it. They're easy to trim off with a process substitution, anyway.

@ghost
Copy link

ghost commented Aug 3, 2017

@konimex I'm not sure, but shouldn't color_blocks"=off" be added to the stdout() function?

@konimex
Copy link
Contributor

konimex commented Aug 3, 2017

I totally forgot about that. My bad.

The color blocks have been disabled. I'm still not sure about whether we should disable line_break or not for stdout mode, but it's the cause of the extra blank lines.

@dylanaraps
Copy link
Owner

dylanaraps commented Aug 4, 2017

Yes, I think we should disable the line breaks.

Edit: Done

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

No branches or pull requests

4 participants