[{"data":1,"prerenderedAt":129},["ShallowReactive",2],{"blog-post-bat-git-diff":3,"recent-posts":85},{"id":4,"uid":5,"url":6,"type":7,"href":8,"tags":9,"first_publication_date":10,"last_publication_date":10,"slugs":11,"linked_documents":13,"lang":14,"alternate_languages":15,"data":16},"awGsAhIAACkAFqOe","bat-git-diff",null,"blog_posts","https:\u002F\u002Fmarks-personal-website.cdn.prismic.io\u002Fapi\u002Fv2\u002Fdocuments\u002Fsearch?ref=awoIKhMAACcAzECF&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22awGsAhIAACkAFqOe%22%29+%5D%5D",[],"2026-11-27T22:46:01+0000",[12],"bat-how-to-use-it-with-git-diff",[],"en-us",[],{"title":17,"date":23,"description":24,"image":29,"content":39},[18],{"type":19,"text":20,"spans":21,"direction":22},"heading1","Bat: How to Use It with git diff",[],"ltr","2026-11-27",[25],{"type":26,"text":27,"spans":28,"direction":22},"heading2","Learn how to use bat with git diff to highlight your changes in the terminal",[],{"dimensions":30,"alt":20,"copyright":6,"url":33,"id":34,"edit":35},{"width":31,"height":32},1280,720,"https:\u002F\u002Fimages.prismic.io\u002Fmarks-personal-website\u002Fhv5njvdg6CY6UfYl_bat-git-diff.png?auto=format,compress","hv5njvdg6CY6UfYl",{"x":36,"y":36,"zoom":37,"background":38},0,1,"transparent",[40,44,48,51,54,57,60,63,66,69,72,75,79,82],{"type":41,"text":42,"spans":43,"direction":22},"paragraph","Before we start, make sure you have \u003Ccode>bat\u003C\u002Fcode> and \u003Ccode>git\u003C\u002Fcode> installed on your computer, and a git repository with some changes in it. If you don't have bat yet, you can install it with Homebrew:",[],{"type":45,"text":46,"spans":47,"direction":22},"preformatted","brew install bat",[],{"type":41,"text":49,"spans":50,"direction":22},"First, open your terminal and navigate to your repository. The quickest way to use bat with git diff is to pipe one into the other:",[],{"type":45,"text":52,"spans":53,"direction":22},"git diff | bat -l diff",[],{"type":41,"text":55,"spans":56,"direction":22},"The \u003Ccode>-l diff\u003C\u002Fcode> flag tells bat to highlight the input as a diff, because it can't guess the language from a pipe.",[],{"type":41,"text":58,"spans":59,"direction":22},"To see your actual code with the changes marked in the margin, bat has the \u003Ccode>--diff\u003C\u002Fcode> flag. Add this helper function to your \u003Ccode>~\u002F.zshrc\u003C\u002Fcode> file:",[],{"type":45,"text":61,"spans":62,"direction":22},"batdiff() {\n    git diff --name-only --relative --diff-filter=d -z | xargs -0 bat --diff\n}",[],{"type":41,"text":64,"spans":65,"direction":22},"Then run \u003Ccode>batdiff\u003C\u002Fcode>. A \u003Ccode>~\u003C\u002Fcode> in the margin marks a modified line and a \u003Ccode>+\u003C\u002Fcode> marks a new one, with a couple of lines of context around each change.",[],{"type":41,"text":67,"spans":68,"direction":22},"If you want git to use bat every time, set it as the diff pager:",[],{"type":45,"text":70,"spans":71,"direction":22},"git config --global pager.diff \"bat --style=plain --language=diff\"",[],{"type":41,"text":73,"spans":74,"direction":22},"The \u003Ccode>--style=plain\u003C\u002Fcode> part removes the line numbers and borders, so they don't clash with git's own hunk headers. Now a normal \u003Ccode>git diff\u003C\u002Fcode> goes through bat automatically.",[],{"type":76,"oembed":77},"embed",{"embed_url":78,"type":76},"",{"type":41,"text":80,"spans":81,"direction":22},"If you want bat to handle all of git's paging, including \u003Ccode>git log\u003C\u002Fcode> and \u003Ccode>git show\u003C\u002Fcode>, set \u003Ccode>core.pager\u003C\u002Fcode> instead:",[],{"type":45,"text":83,"spans":84,"direction":22},"git config --global core.pager \"bat --style=plain\"",[],{"results":86,"page":37,"results_per_page":127,"results_size":127,"total_results_size":128,"total_pages":37},[87,106,108],{"id":88,"uid":89,"url":6,"type":7,"href":90,"tags":91,"first_publication_date":10,"last_publication_date":10,"slugs":92,"linked_documents":94,"lang":14,"alternate_languages":95,"data":96},"awGsBRIAAC0AFqOw","httpie-pretty-print-json","https:\u002F\u002Fmarks-personal-website.cdn.prismic.io\u002Fapi\u002Fv2\u002Fdocuments\u002Fsearch?ref=awoIKhMAACcAzECF&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22awGsBRIAAC0AFqOw%22%29+%5D%5D",[],[93],"httpie-how-to-pretty-print-json",[],[],{"image":97,"title":103},{"dimensions":98,"alt":99,"copyright":6,"url":100,"id":101,"edit":102},{"width":31,"height":32},"HTTPie: How to Pretty Print JSON","https:\u002F\u002Fimages.prismic.io\u002Fmarks-personal-website\u002FlCNUDBWv_1DmEc9s_httpie-pretty-print-json.png?auto=format,compress","lCNUDBWv_1DmEc9s",{"x":36,"y":36,"zoom":37,"background":38},[104],{"type":19,"text":99,"spans":105,"direction":22},[],{"id":4,"uid":5,"url":6,"type":7,"href":8,"tags":9,"first_publication_date":10,"last_publication_date":10,"slugs":11,"linked_documents":13,"lang":14,"alternate_languages":15,"data":107},{"image":29,"title":17},{"id":109,"uid":110,"url":6,"type":7,"href":111,"tags":112,"first_publication_date":10,"last_publication_date":10,"slugs":113,"linked_documents":115,"lang":14,"alternate_languages":116,"data":117},"awGsBBIAACsAFqOq","bat-hide-file-header","https:\u002F\u002Fmarks-personal-website.cdn.prismic.io\u002Fapi\u002Fv2\u002Fdocuments\u002Fsearch?ref=awoIKhMAACcAzECF&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22awGsBBIAACsAFqOq%22%29+%5D%5D",[],[114],"bat-how-to-hide-the-file-header",[],[],{"image":118,"title":124},{"dimensions":119,"alt":120,"copyright":6,"url":121,"id":122,"edit":123},{"width":31,"height":32},"Bat: How to Hide the File Header","https:\u002F\u002Fimages.prismic.io\u002Fmarks-personal-website\u002F7ZkXhTyVPYMIyYzS_bat-hide-file-header.png?auto=format,compress","7ZkXhTyVPYMIyYzS",{"x":36,"y":36,"zoom":37,"background":38},[125],{"type":19,"text":120,"spans":126,"direction":22},[],3,104,1795819585984]