/pipelight

highlight differences between two command outputs

Primary LanguageGo

pipelight

'cause it shows the difference

Install

go get github.com/arbovm/pipelight

Example

» date -clear | pipelight

Fri Mar 1 18:53:49 CET 2013

It shows the date, awesome. Let's run it again:

» date | pipelight

Fri Mar 1 18:53:54 CET 2013

It highlights the seconds of the date output because they changed since the last time the command was executed. OK, that doesn't make any sense. But what about this:

curl -Is https://github.com -c cookies.txt -b cookies.txt| pipelight -clear

HTTP/1.1 200 OK
Server: GitHub.com
Date: Fri, 01 Mar 2013 18:26:17 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Status: 200 OK
Cache-Control: private, max-age=0, must-revalidate
Strict-Transport-Security: max-age=2592000
X-Frame-Options: deny
Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Tue, 01-Mar-2033 18:26:17 GMT
Set-Cookie: _gh_sess=BAh7Bz...d25af3; path=/; expires=Sun, 01-Jan-2023 00:00:00 GMT; secure; HttpOnly
X-Runtime: 6
ETag: "61b566ab19f54e54bf0dcee24a3dac19"
Content-Length: 10925

And execute it again:

curl -Is https://github.com -c cookies.txt -b cookies.txt| pipelight

HTTP/1.1 200 OK
Server: GitHub.com
Date: Fri, 01 Mar 2013 18:26:21 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Status: 200 OK
Cache-Control: private, max-age=0, must-revalidate
Strict-Transport-Security: max-age=2592000
X-Frame-Options: deny
Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Tue, 01-Mar-2033 18:26:21 GMT
Set-Cookie: _gh_sess=BAh7Bz...d25af3; path=/; expires=Sun, 01-Jan-2023 00:00:00 GMT; secure; HttpOnly
X-Runtime: 7
ETag: "20766f7927ccf5643ba845ac381917ab"
Content-Length: 10925

Now it shows, that only X-Runtime, Date and parts of the ETag changed.

Let's try this again using Accept-Encoding: gzip to force compresssion:

curl -Is https://github.com -c cookies.txt -b cookies.txt -H'Accept-Encoding: gzip' | pipelight

HTTP/1.1 200 OK
Server: GitHub.com
Date: Fri, 01 Mar 2013 18:26:41 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Status: 200 OK
Cache-Control: private, max-age=0, must-revalidate
Strict-Transport-Security: max-age=2592000
X-Frame-Options: deny
Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Tue, 01-Mar-2033 18:26:41 GMT
Set-Cookie: _gh_sess=BAh7Bz...d25af3; path=/; expires=Sun, 01-Jan-2023 00:00:00 GMT; secure; HttpOnly
X-Runtime: 6
ETag: "de2ca9b0eba7131fdf5de1d6fcb461f4"
Content-Encoding: gzip

And it highlights the new response header Content-Encoding ( instead of sending Content-Length ).

TODO

  • Add clear command
  • Make way of highlighting configurable
  • Find similar lines to provide a better highlighting
  • Add option to hide unchanged lines