{"id":246318,"date":"2022-07-15T09:47:03","date_gmt":"2022-07-15T01:47:03","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=246318"},"modified":"2022-07-04T12:47:55","modified_gmt":"2022-07-04T04:47:55","slug":"linux-bat","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-bat.html","title":{"rendered":"Linux \u67e5\u770b\u6587\u4ef6\u5185\u5bb9\u2014\u2014bat \u547d\u4ee4"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nwhat's the bat
\n\u5de5\u4f5c\u4e2d\u4f7f\u7528\u00a0\u200b\u200bcat\u200b\u200b\u00a0\u7684\u9891\u7387\u8f83\u9ad8\uff0c\u4e3b\u8981\u7528\u4e8e\u663e\u793a\u6587\u672c\u6587\u4ef6\u7684\u5177\u4f53\u5185\u5bb9\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u4f46\u00a0\u200b\u200bcat\u200b\u200b\u00a0\u547d\u4ee4\u4e24\u4e2a\u5f88\u91cd\u5927\u7684\u7f3a\u9677\uff1a
\n\"\"
\n\u4e0d\u80fd\u8bed\u6cd5\u9ad8\u4eae\u8f93\u51fa
\n\u6587\u672c\u592a\u957f\u7684\u8bdd\u65e0\u6cd5\u7ffb\u9875\u8f93\u51fa\u3002
\n\u6240\u4ee5\u00a0\u200b\u200bcat\u200b\u200b\u200b\u00a0\u4e00\u822c\u53ea\u7528\u6765\u67e5\u770b\u884c\u6570\u4e0d\u591a\u7684\u5c0f\u6587\u4ef6\uff0c\u5927\u6587\u4ef6\u9700\u8981\u7528\u5230\u00a0\u200b\u200bhead\u3001tail\u200b\u200b\u00a0\u7b49\u547d\u4ee4\u3002<\/p>\n

\u56fd\u5916\u6709\u5927\u725b\u5c06\u00a0\u200b\u200bcat\u200b\u200b\u200b\u00a0\u547d\u4ee4\u8fdb\u884c\u4e86\u589e\u5f3a\uff0c\u5f00\u53d1\u4e86\u66f4\u597d\u7528\u7684\u00a0\u200b\u200bbat\u200b\u200b\u00a0\u547d\u4ee4\u3002<\/p>\n

\u200b\u200b<\/p>\n

bat\u200b\u200b\u00a0\u4e3b\u8981\u529f\u80fd\uff1a<\/strong><\/div>\n

\u8bed\u6cd5\u9ad8\u4eae\u2014\u2014\u652f\u6301\u6839\u636e\u7f16\u7a0b\u8bed\u8a00\u4ee5\u53ca markdown \u8bed\u6cd5\u5c06\u6587\u672c\u5173\u952e\u8bcd\u9ad8\u4eae\uff0c\u53ef\u9605\u8bfb\u6027\u5927\u5927\u589e\u5f3a\uff1b
\n\u81ea\u52a8\u7ffb\u9875\u2014\u2014\u5982\u679c\u6587\u672c\u5185\u5bb9\u592a\u957f\uff0c\u8d85\u8fc7\u4e00\u9875\u7684\u8bdd\uff0c\u5b83\u4f1a\u81ea\u52a8\u5c06\u5185\u5bb9\u901a\u8fc7\u7ba1\u9053\u4f20\u5230\u200b\u200bless\u200b\u200b\u00a0\u547d\u4ee4\uff0c\u5b9e\u73b0\u7ffb\u9875\u7684\u6548\u679c\uff1b
\n\u96c6\u6210Git\u2014\u2014\u200b\u200bbat\u200b\u200b\u00a0\u547d\u4ee4\u8ddf git \u5b8c\u7f8e\u7ed3\u5408\uff0c\u5c06\u6587\u672c\u7684\u4fee\u6539\u90e8\u5206\u5728\u5de6\u4fa7\u5c55\u793a\uff0c\u4e00\u773c\u5c31\u53ef\u4ee5\u770b\u51fa\u6587\u4ef6\u4fee\u6539\u4e86\u5565\u3002
\n\u663e\u793a\u4e0d\u53ef\u6253\u5370\u5b57\u7b26\u2014\u2014\u6709\u4e9b\u5b57\u7b26\u65e0\u6cd5\u901a\u8fc7\u200b\u200bcat\u200b\u200b\u00a0\u5728\u5c4f\u5e55\u4e0a\u663e\u793a
\n\u5b89\u88c5<\/p>\n

sudo apt-get install bat<\/pre>\n

\u8fd9\u91cc\u8981\u6ce8\u610f\u4e00\u4e0b\uff0c\u7531\u4e8e\u540d\u79f0\u7684\u51b2\u7a81\uff0c\u5728 Ubuntu \u4e0b\u65e0\u6cd5\u76f4\u63a5\u901a\u8fc7\u6572 bat \u8fd9\u4e09\u4e2a\u5b57\u6bcd\u8fd0\u884c\u00a0\u200b\u200bbat\u200b\u200b\u200b\u00a0\u547d\u4ee4\uff0c\u800c\u662f\u9700\u8981\u6572\u00a0\u200b\u200bbatcat\u200b\u200b\u00a0\u3002\u4e3a\u4e86\u65b9\u4fbf\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u522b\u540d<\/p>\n

alias \"bat=batcat\"<\/pre>\n
\u4f7f\u7528\u65b9\u6cd5<\/strong><\/div>\n
\u57fa\u672c\u4f7f\u7528<\/strong><\/span><\/div>\n

\u200b\u200b\u3000\u3000bat\u200b\u200b\u200b\u00a0\u547d\u4ee4\u7684\u7528\u6cd5\u8ddf\u00a0\u200b\u200bcat\u200b\u200b\u200b\u00a0\u57fa\u672c\u76f8\u540c\uff0c\u9664\u4e86\u8f93\u51fa\u4e0e\u00a0\u200b\u200bcat\u200b\u200b\u200b\u00a0\u4e00\u6837\u7684\u6587\u672c\u5185\u5bb9\u4e4b\u5916\uff0c\u8fd8\u80fd\u8f93\u51fa\u5305\u62ec\u884c\u6570\u3001\u6587\u4ef6\u540d\u3001\u8868\u683c\u5916\u6846\u7b49\u5143\u7d20\u3002\u5982\u679c\u884c\u6570\u6bd4\u8f83\u591a\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u00a0\u200b\u200b--line-range\u200b\u200b\u00a0\u6765\u663e\u793a\u6307\u5b9a\u884c\u6570\u7684\u5185\u5bb9<\/p>\n

\u8bed\u6cd5\u9ad8\u4eae<\/strong><\/div>\n

\u200b\u200b\u3000\u3000bat\u200b\u200b\u00a0\u5bf9\u5927\u90e8\u5206\u7f16\u7a0b\u8bed\u8a00\u548c\u6807\u8bb0\u8bed\u8a00\u63d0\u4f9b\u8bed\u6cd5\u9ad8\u4eae\uff0c\u53ef\u8bfb\u6027\u66f4\u5f3a\u3002<\/p>\n

\u67e5\u770b\u6240\u6709\u652f\u6301\u7684\u8bed\u8a00<\/p>\n

bat --list-languages<\/pre>\n
Git \u96c6\u6210<\/strong><\/div>\n

\u200b\u200b\u3000\u3000bat\u200b\u200b\u00a0\u80fd\u4ece git \u4e2d\u83b7\u53d6\u6587\u4ef6\u7684\u4fee\u6539\u5e76\u5c55\u793a\u5728\u8fb9\u680f<\/p>\n

\u663e\u793a\u4e0d\u53ef\u6253\u5370\u5b57\u7b26<\/strong><\/div>\n

\u6709\u65f6\u5019\u6587\u672c\u91cc\u6709\u4e00\u4e9b\u4e0d\u53ef\u663e\u793a\u7684\u5b57\u7b26\uff0c\u5982\u679c\u4f7f\u7528\u00a0\u200b\u200bcat\u200b\u200b\u200b\u00a0\u547d\u4ee4\u67e5\u770b\u7684\u8bdd\uff0c\u5c06\u770b\u4e0d\u5230\u8fd9\u4e9b\u5b57\u7b26\u3002\u4f46\u5982\u679c\u4f7f\u7528\u00a0\u200b\u200bbat\u200b\u200b\u200b\u00a0\u547d\u4ee4\uff0c\u52a0\u4e0a\u00a0\u200b\u200b-A\u200b\u200b\u200b\u00a0\u6216\u8005\u00a0\u200b\u200b-show-all\u200b\u200b\u00a0\u53c2\u6570\u5c31\u80fd\u770b\u5230\u3002<\/p>\n

bat -A xxx.txt<\/pre>\n
\u81ea\u52a8\u7ffb\u9875\u529f\u80fd<\/strong><\/div>\n

\u200b\u200bcat\u200b\u200b\u200b\u00a0\u547d\u4ee4\u4e0d\u7ba1\u6587\u672c\u5927\u5c0f\u5168\u90e8\u663e\u793a\u51fa\u6765\uff0c\u4f7f\u5f97\u5728\u9700\u8981\u67e5\u770b\u5185\u5bb9\u6bd4\u8f83\u591a\u7684\u6587\u672c\u6587\u4ef6\u7684\u65f6\u5019\uff0c\u5fc5\u987b\u9009\u62e9\u5176\u5b83\u547d\u4ee4\uff08\u6bd4\u5982\u00a0\u200b\u200bmore\u200b\u200b\u200b\u00a0\u3001\u200b\u200bless\u200b\u200b\u00a0\u7b49\u7b49\uff09\u3002<\/p>\n

\u200b\u200bbat\u200b\u200b\u200b\u00a0\u547d\u4ee4\u5728\u6587\u672c\u5185\u5bb9\u8d85\u8fc7\u4e00\u5c4f\u53ef\u663e\u793a\u8303\u56f4\u65f6\uff0c\u5c31\u4f1a\u5c06\u5176\u53d1\u9001\u5230\u00a0\u200b\u200bless\u200b\u200b\u200b\u00a0\u547d\u4ee4\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u50cf\u4f7f\u7528\u00a0\u200b\u200bless\u200b\u200b\u200b\u00a0\u4e00\u6837\u8fdb\u884c\u7ffb\u9875\u64cd\u4f5c\u3002\u5982\u679c\u4e0d\u60f3\u4f7f\u7528\u7ffb\u9875\u529f\u80fd\uff0c\u53ef\u4ee5\u4f7f\u7528\u00a0\u200b\u200b--paging=never\u200b\u200b\u00a0\u53c2\u6570\u5173\u95ed\u3002<\/p>\n

\u4e3b\u9898\u5b9a\u5236<\/strong><\/div>\n

\u200b\u200b\u3000\u3000bat\u200b\u200b\u00a0\u547d\u4ee4\u652f\u6301\u591a\u79cd\u98ce\u683c\u7684\u8bed\u6cd5\u9ad8\u4eae\u4e3b\u9898\uff0c\u53ef\u4ee5\u6ee1\u8db3\u5927\u90e8\u5206\u9700\u6c42\u3002<\/p>\n

\u67e5\u770b\u00a0\u200b\u200bbat\u200b\u200b\u00a0\u652f\u6301\u7684\u6240\u6709\u4e3b\u9898<\/p>\n

bat --list-themes<\/pre>\n

\u5982\u679c\u60f3\u6307\u5b9a\u4e3b\u9898\u4e3a\u00a0\u200b\u200bGitHub\u200b\u200b\u00a0\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4<\/p>\n

bat --theme=GitHub \u6587\u4ef6\u540d<\/pre>\n

\u4f46\u8fd9\u6837\u505a\u662f\u4e34\u65f6\u7684\uff0c\u5173\u95ed\u7ec8\u7aef\u5de5\u5177\u6216\u8005\u7cfb\u7edf\u91cd\u542f\uff0c\u4e3b\u9898\u5c31\u4f1a\u6062\u590d\u9ed8\u8ba4\u3002\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u00a0\u200b\u200bBAT_THEME\u200b\u200b\u00a0\u73af\u5883\u53d8\u91cf\u6765\u9009\u5b9a\u4e3b\u9898\u3002<\/p>\n

\u628a\u00a0\u200b\u200bexport BAT_THEME=\"GitHub\"\u200b\u200b\u00a0\u6dfb\u52a0\u5230 shell \u7684\u542f\u52a8\u811a\u672c\u6765\u53d6\u5f97\u6c38\u4e45\u6548\u679c\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u53ef\u4ee5\u81ea\u5b9a\u4e49\u8f93\u51fa\u6837\u5f0f\uff0c\u751a\u81f3\u53ef\u4ee5\u81ea\u5df1\u6dfb\u52a0\u65b0\u7684\u8bed\u8a00\u548c\u8bed\u6cd5\uff0c\u8f93\u51fa\u8ba9\u81ea\u5df1\u6ee1\u610f\u7684\u9ad8\u4eae\u6837\u5f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4f46\u00a0\u200b\u200bcat\u200b\u200b\u00a0\u547d\u4ee4\u4e24\u4e2a\u5f88\u91cd\u5927\u7684\u7f3a\u9677\uff1a \u4e0d\u80fd\u8bed\u6cd5\u9ad8\u4eae\u8f93\u51fa \u6587\u672c\u592a\u957f\u7684\u8bdd\u65e0\u6cd5\u7ffb\u9875\u8f93\u51fa\u3002 \u6240\u4ee5\u00a0\u200b\u200bcat\u200b\u200b […]<\/p>\n","protected":false},"author":1469,"featured_media":246322,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-246318","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/246318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1469"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=246318"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/246318\/revisions"}],"predecessor-version":[{"id":246323,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/246318\/revisions\/246323"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/246322"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=246318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=246318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=246318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}