Skip to content

Instantly share code, notes, and snippets.

@nijikokun
Last active January 24, 2024 08:48
Show Gist options
  • Save nijikokun/d6606c036d89d3b1574c to your computer and use it in GitHub Desktop.
Save nijikokun/d6606c036d89d3b1574c to your computer and use it in GitHub Desktop.
Cool ways to Diff two HTTP Requests in your terminal!

Basic diffing

  • Line by line
  • No colors
  • Able to be piped into vim (shown later on)
diff <(curl -vs https://reddit.com 2>&1) <(curl -vs https://reddit.com 2>&1)

Advanced diffing

  • Side by side
  • No colors
  • Not able to be piped into vim
diff -y -W $COLUMNS <(curl -Lvs https://www.google.com/ 2>&1) <(curl -Lvs http://www.google.com/ 2>&1)

Colordiffed

  • Requires colordiff
    • yum install colordiff
    • apt-get install colordiff
    • brew install colordiff
  • Colored (buggy)
  • Line by line or Side by side
colordiff -y -W $COLUMNS <(curl -Lvs https://www.google.com/ 2>&1) <(curl -Lvs http://www.google.com/ 2>&1)

Vim Piped Diff

  • Line by line
  • Colored
  • Editable
diff <(curl -Lvs https://www.google.com/ 2>&1) <(curl -Lvs http://www.google.com/ 2>&1) | vim -R -

Vim Diffing

  • Side by side diff
  • Colored
  • Editable
vim -d <(curl -Lvs https://www.google.com/ 2>&1) <(curl -Lvs http://www.google.com/ 2>&1)

Diffr Diffing

  • Requires Diffr
    • npm install diffr -g
  • Line by line diff & Side by side diff -c option
  • Colored
diffr <(curl -Lvs https://www.google.com/ 2>&1) <(curl -Lvs http://www.google.com/ 2>&1)

Notes

If $COLUMNS doesn't work

Try -yW"`tput cols`"

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