--pretty=all piped to a pager does not work on Windows
I am trying to use --pretty=all or --pretty=colors to color my output that I am piping to less -r. However, the colors do not show. This could also be solved by adding a paging option for long outputs (like in Git), but I understand that that is much more difficult. I am running this in Git Bash 2.21.0, and also in CMD on Windows piping to more. Neither do the coloring.
$ http --debug --pretty=all https://api.github.com | less -r
HTTPie 1.0.2
Requests 2.22.0
Pygments 2.4.2
Python 3.8.0a1 (tags/v3.8.0a1:e75eeb00b5, Feb 3 2019, 20:47:39) [MSC v.1916 64 bit (AMD64)]
c:\users\josepstr\appdata\local\programs\python\python38\python.exe
Windows 10
<Environment {
"colors": 256,
"config": {
"__meta__": {
"about": "HTTPie configuration file",
"help": "https://httpie.org/doc#config",
"httpie": "1.0.2"
},
"default_options": "['--ignore-stdin', '--print=hb']"
},
"config_dir": "C:\\Users\\josepstr\\AppData\\Roaming\\\\httpie",
"is_windows": true,
"stderr": "<colorama.ansitowin32.StreamWrapper object at 0x0000022778437820>",
"stderr_isatty": false,
"stdin": "<_io.TextIOWrapper name='<stdin>' mode='r' encoding='cp1252'>",
"stdin_encoding": "cp1252",
"stdin_isatty": false,
"stdout": "<colorama.ansitowin32.StreamWrapper object at 0x00000227784379A0>",
"stdout_encoding": "cp1252",
"stdout_isatty": false
}>
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Cache-Control: public, max-age=60, s-maxage=60
Content-Encoding: gzip
Content-Security-Policy: default-src 'none'
Content-Type: application/json; charset=utf-8
Date: Fri, 16 Aug 2019 14:02:10 GMT
ETag: W/"7dc470913f1fe9bb6c7355b50a0737bc"
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Server: GitHub.com
Status: 200 OK
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Transfer-Encoding: chunked
Vary: Accept
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-GitHub-Media-Type: github.v3; format=json
X-GitHub-Request-Id: B6A5:47F7:1F73AB:2A67EC:5D56B762
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 1565967730
X-XSS-Protection: 1; mode=block
{
"authorizations_url": "https://api.github.com/authorizations",
"code_search_url": "https://api.github.com/search/code?q={query}{&page,per_page,sort,order}",
"commit_search_url": "https://api.github.com/search/commits?q={query}{&page,per_page,sort,order}",
"current_user_authorizations_html_url": "https://github.com/settings/connections/applications{/client_id}",
"current_user_repositories_url": "https://api.github.com/user/repos{?type,page,per_page,sort}",
"current_user_url": "https://api.github.com/user",
"emails_url": "https://api.github.com/user/emails",
"emojis_url": "https://api.github.com/emojis",
"events_url": "https://api.github.com/events",
"feeds_url": "https://api.github.com/feeds",
"followers_url": "https://api.github.com/user/followers",
"following_url": "https://api.github.com/user/following{/target}",
"gists_url": "https://api.github.com/gists{/gist_id}",
"hub_url": "https://api.github.com/hub",
"issue_search_url": "https://api.github.com/search/issues?q={query}{&page,per_page,sort,order}",
"issues_url": "https://api.github.com/issues",
"keys_url": "https://api.github.com/user/keys",
"notifications_url": "https://api.github.com/notifications",
"organization_repositories_url": "https://api.github.com/orgs/{org}/repos{?type,page,per_page,sort}",
"organization_url": "https://api.github.com/orgs/{org}",
"public_gists_url": "https://api.github.com/gists/public",
"rate_limit_url": "https://api.github.com/rate_limit",
"repository_search_url": "https://api.github.com/search/repositories?q={query}{&page,per_page,sort,order}",
"repository_url": "https://api.github.com/repos/{owner}/{repo}",
"starred_gists_url": "https://api.github.com/gists/starred",
"starred_url": "https://api.github.com/user/starred{/owner}{/repo}",
"team_url": "https://api.github.com/teams",
"user_organizations_url": "https://api.github.com/user/orgs",
"user_repositories_url": "https://api.github.com/users/{user}/repos{?type,page,per_page,sort}",
"user_search_url": "https://api.github.com/search/users?q={query}{&page,per_page,sort,order}",
"user_url": "https://api.github.com/users/{user}"
}
>>> requests.request(**{
"allow_redirects": false,
"auth": "None",
"cert": "None",
"data": {},
"files": {},
"headers": {
"User-Agent": "HTTPie/1.0.2"
},
"method": "get",
"params": {},
"proxies": {},
"stream": true,
"timeout": 30,
"url": "https://api.github.com",
"verify": true
})
I will look into it
I was able to replicate the issue using the 'more' command on windows. I wonder if it colors the output on Unix/Linux, @jakubroztocil, when piping the output to less.
@ovezovs yes, the following command should result in colorized output shown in less (notice the -r):
http --pretty=all httpbin.org/get | less -r
@jkstrauss which windows console did you use?
@ovezovs yes, the following command should result in colorized output shown in
less(notice the-r):http --pretty=all httpbin.org/get | less -r@jkstrauss which windows console did you use?
I used PowerShell and VS Code terminal
@ovezovs more also supports/requires -r:
http --pretty=all httpbin.org/get | more -r