curl: show headers in bold #2538

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
5 participants
@bagder
Member

bagder commented Apr 27, 2018

The feature is only enabled if the output is believed to be a tty.

-J: There's some minor differences and improvements in -J handling, as
now J should work with -i and it actually creates a file first using the
initial name and then renames that to the one found in
Content-Disposition (if any).

-i: only shows headers for HTTP transfers now (as documented).
Previously it would also show for pieces of the transfer that were HTTP
(for example when doing FTP over a HTTP proxy).

-i: now shows trailers as well. Previously they were not shown at all.

--libcurl: the CURLOPT_HEADER is no longer set, as the header output is
now done in the header callback.

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Apr 27, 2018

Member

Sample look: image

Member

bagder commented Apr 27, 2018

Sample look: image

@jay

This comment has been minimized.

Show comment
Hide comment
@jay

jay Apr 27, 2018

Member

The windows console doesn't treat ansi escape codes as special, and as far as I know bold isn't possible

You will probably need to do something like this
#ifdef WIN32
#define BOLD_ON
#else
#define BOLD_ON "\x1b[1m"
#endif
and same for bold off

Member

jay commented Apr 27, 2018

The windows console doesn't treat ansi escape codes as special, and as far as I know bold isn't possible

You will probably need to do something like this
#ifdef WIN32
#define BOLD_ON
#else
#define BOLD_ON "\x1b[1m"
#endif
and same for bold off

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Apr 28, 2018

Member

The windows console doesn't treat ansi escape codes as special

The question is perhaps if there's a chance the curl executable might be used in a terminal/console on windows that supports them? If so, that might require us to toggle this feature on/off depending on the terminal type in use...

Member

bagder commented Apr 28, 2018

The windows console doesn't treat ansi escape codes as special

The question is perhaps if there's a chance the curl executable might be used in a terminal/console on windows that supports them? If so, that might require us to toggle this feature on/off depending on the terminal type in use...

@BobVul

This comment has been minimized.

Show comment
Hide comment
@BobVul

BobVul Apr 30, 2018

The windows console doesn't treat ansi escape codes as special

Technically, it does support the bold escape sequence in the most recent versions. Except conhost renders it as the bright version of the current colour, not bold.

In a completely default cmd-in-conhost window, this means bold is bright white and normal (default) text is (dim) white, so you do still benefit from the colour difference. In a default powershell-in-conhost window, normal (default) text is already bright white and setting 'bold' makes no difference.

This would also depend on the curl executable setting the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag (it's not passed along by built-in shells, i.e. cmd & powershell).

BobVul commented Apr 30, 2018

The windows console doesn't treat ansi escape codes as special

Technically, it does support the bold escape sequence in the most recent versions. Except conhost renders it as the bright version of the current colour, not bold.

In a completely default cmd-in-conhost window, this means bold is bright white and normal (default) text is (dim) white, so you do still benefit from the colour difference. In a default powershell-in-conhost window, normal (default) text is already bright white and setting 'bold' makes no difference.

This would also depend on the curl executable setting the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag (it's not passed along by built-in shells, i.e. cmd & powershell).

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder May 14, 2018

Member

Rebased and now disabled on Windows.

Member

bagder commented May 14, 2018

Rebased and now disabled on Windows.

@bagder bagder changed the title from curl: show headers in bold (WIP) to curl: show headers in bold May 17, 2018

bagder added some commits May 17, 2018

curl: show headers in bold
The feature is only enabled if the output is believed to be a tty.

-J: There's some minor differences and improvements in -J handling, as
now J should work with -i and it actually creates a file first using the
initial name and then *renames* that to the one found in
Content-Disposition (if any).

-i: only shows headers for HTTP transfers now (as documented).
Previously it would also show for pieces of the transfer that were HTTP
(for example when doing FTP over a HTTP proxy).

-i: now shows trailers as well. Previously they were not shown at all.

--libcurl: the CURLOPT_HEADER is no longer set, as the header output is
now done in the header callback.
curl: added --styled-output
It is enabled by default, so --no-styled-output will switch off the
detection/use of bold headers.

@bagder bagder closed this in f3d836b May 21, 2018

@bagder bagder deleted the bagder/bold-headers branch May 21, 2018

@jindraj

This comment has been minimized.

Show comment
Hide comment
@jindraj

jindraj Jul 11, 2018

There's different behaviour for
curl --styled-output -D - url
and
curl --styled-output -I url
While -I shows headers in bold, -D - doesn't.
Is that expected behaviour?

jindraj commented Jul 11, 2018

There's different behaviour for
curl --styled-output -D - url
and
curl --styled-output -I url
While -I shows headers in bold, -D - doesn't.
Is that expected behaviour?

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Jul 11, 2018

Member

It is expected since I only enabled it for -I and -i. But I believe it should be possible to add for "-D -" too...

Member

bagder commented Jul 11, 2018

It is expected since I only enabled it for -I and -i. But I believe it should be possible to add for "-D -" too...

@jindraj

This comment has been minimized.

Show comment
Hide comment
@jindraj

jindraj Jul 12, 2018

I never used -i, but it's almost the same as -D -.

curl -i example.com prints even HTML in bold. At least for me. I have curl 7.61.0 installed from brew on macOS.

jindraj commented Jul 12, 2018

I never used -i, but it's almost the same as -D -.

curl -i example.com prints even HTML in bold. At least for me. I have curl 7.61.0 installed from brew on macOS.

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Jul 12, 2018

Member

See #2736 and #2738

Member

bagder commented Jul 12, 2018

See #2736 and #2738

@xvybihal

This comment has been minimized.

Show comment
Hide comment
@xvybihal

xvybihal Jul 13, 2018

From left to right: LilyTerm, Termit, Gnome Terminal, Terminator.

https://i.imgur.com/EFD1XJW.png

xvybihal commented Jul 13, 2018

From left to right: LilyTerm, Termit, Gnome Terminal, Terminator.

https://i.imgur.com/EFD1XJW.png

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Jul 14, 2018

Member

@xvybihal but how does the fix in #2738 work on those?

Member

bagder commented Jul 14, 2018

@xvybihal but how does the fix in #2738 work on those?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment