CentOs7 catコマンドをより見やすくする「bat」をインストールする

linuxのコマンドの1つcatをより見やすくする「bat」をインストールして利用するまでの手順を記述してます。
環境
- OS CentOS Linux release 7.8.2003 (Core)
batインストール
まずはダウンロードを行います。バージョンはこちらで確認できます。
1 |
wget -O bat.zip https://github.com/sharkdp/bat/releases/download/v0.15.4/bat-v0.15.4-x86_64-unknown-linux-musl.tar.gz |
解凍します。
1 |
tar -xvzf bat.zip -C /usr/local |
移動させます。
1 |
mv /usr/local/bat-v0.15.4-x86_64-unknown-linux-musl/ /usr/local/bat |
.bashrcに下記を追加します。
1 2 3 4 |
vi ~/.bashrc <編集> alias bat='/usr/local/bat/bat' |
反映させます。
1 |
source ~/.bashrc |
バージョンを確認します。
1 2 3 4 |
bat --version <出力結果> bat 0.15.4 |
bat使い方
適当なhtmlを作成したbatコマンドで確認してみます。
1 |
bat test.html |
実行結果は、下図の通り「シンタックスハイライト」表示されて表示されます。

対応している言語は、下記のコマンドで確認できます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
bat --list-languages <出力結果> ActionScript as Advanced CSV csv, tsv AppleScript applescript, script editor ARM Assembly s, S AsciiDoc adoc, asciidoc, asc ASP asa Assembly (x86_64) yasm, nasm, asm, inc, mac Authorized Keys authorized_keys, pub AWK awk Batch File bat, cmd BibTeX bib Bourne Again Shell (bash) sh, bash, zsh, ash, .bash_aliases, .bash_completions, .bash_functions, .bash_login, .bash_logout, .bash_profile, .bash_variables, .bashrc, .profile, .textmate_init, .zlogin, .zlogout, .zprofile, .zshenv, .zshrc, PKGBUILD, .ebuild, .eclass C c, h C# cs, csx C++ cpp, cc, cp, cxx, c++, C, h, hh, hpp, hxx, h++, inl, ipp Cabal cabal Clojure clj, cljc, cljs, edn CMake CMakeLists.txt, cmake CMake C Header h.in CMake C++ Header hh.in, hpp.in, hxx.in, h++.in CMakeCache CMakeCache.txt CoffeeScript coffee, Cakefile, coffee.erb, cson CpuInfo cpuinfo Crystal cr CSS css, css.erb, css.liquid D d, di Dart dart Diff diff, patch Dockerfile Dockerfile, dockerfile DotENV .env, .envrc, .env.dist, .env.local, .env.sample, .env.example, .env.test, .env.test.local, .env.testing, .env.dev, .env.development, .env.development.local, .env.prod, .env.production, .env.production.local, .env.dusk.local, .flaskenv, .env.staging Elixir ex, exs Elm elm Email eml, msg, mbx, mboxz Erlang erl, hrl, Emakefile, emakefile, escript F# fs, fsi, fsx Fortran (Fixed Form) f, F, f77, F77, for, FOR, fpp, FPP Fortran (Modern) f90, F90, f95, F95, f03, F03, f08, F08 Fortran Namelist namelist Friendly Interactive Shell (fish) fish fstab fstab Git Attributes attributes, gitattributes, .gitattributes Git Commit COMMIT_EDITMSG, MERGE_MSG, TAG_EDITMSG Git Config gitconfig, .gitconfig, .gitmodules Git Ignore exclude, gitignore, .gitignore Git Link .git Git Log gitlog Git Mailmap .mailmap, mailmap Git Rebase Todo git-rebase-todo Go go GraphQL graphql, gql Graphviz (DOT) dot, DOT, gv Groovy groovy, gvy, gradle, Jenkinsfile group group Haskell hs Highlight non-printables show-nonprintable hosts hosts HTML html, htm, shtml, xhtml HTML (ASP) asp HTML (EEx) html.eex HTML (Erlang) yaws HTML (Jinja2) htm.j2, html.j2, xhtml.j2, xml.j2 HTML (Rails) rails, rhtml, erb, html.erb HTML (Tcl) adp HTML (Twig) twig, html.twig INI ini, INI, INF, reg, REG, lng, cfg, CFG, desktop, url, URL, .editorconfig, .hgrc, hgrc Java java, bsh Java Properties properties Java Server Page (JSP) jsp JavaScript js, htc JavaScript (Babel) js, mjs, jsx, babel, es6, cjs JavaScript (Rails) js.erb Jinja2 j2, jinja2, jinja JSON json, sublime-settings, sublime-menu, sublime-keymap, sublime-mousemap, sublime-theme, sublime-build, sublime-project, sublime-completions, sublime-commands, sublime-macro, sublime-color-scheme, ipynb, Pipfile.lock jsonnet jsonnet, libsonnet, libjsonnet Julia jl Known Hosts known_hosts Kotlin kt, kts LaTeX tex, ltx Less less, css.less Lisp lisp, cl, clisp, l, mud, el, scm, ss, lsp, fasl Literate Haskell lhs Lua lua Makefile make, GNUmakefile, makefile, Makefile, makefile.am, Makefile.am, makefile.in, Makefile.in, OCamlMakefile, mak, mk Manpage man Markdown md, mdown, markdown, markdn MATLAB matlab MemInfo meminfo NAnt Build File build Nim nim, nims Nix nix Objective-C m, h Objective-C++ mm, M, h OCaml ml, mli OCamllex mll OCamlyacc mly orgmode org Pascal pas, p, dpr passwd passwd Perl pl, pc, pm, pmc, pod, t PHP php, php3, php4, php5, php7, phps, phpt, phtml Plain Text txt PowerShell ps1, psm1, psd1 Protocol Buffer proto, protodevel Protocol Buffer (TEXT) pb.txt, proto.text, textpb, pbtxt, prototxt Puppet pp, epp PureScript purs Python py, py3, pyw, pyi, pyx, pyx.in, pxd, pxd.in, pxi, pxi.in, rpy, cpy, SConstruct, Sconstruct, sconstruct, SConscript, gyp, gypi, Snakefile, vpy, wscript, bazel, bzl QML qml, qmlproject R R, r, Rprofile Rd (R Documentation) rd Rego rego Regular Expression re requirements.txt requirements.txt TypeScript ts TypeScriptReact tsx varlink varlink Verilog v, V VimL vim, .vimrc Vue Component vue XML xml, xsd, xslt, tld, dtml, rng, rss, opml, svg YAML yaml, yml, sublime-syntax |
-
前の記事
javascript 文字列の一部を抽出する 2020.08.09
-
次の記事
ubuntu20.04 容量の大きいパッケージを検索して削除する手順 2020.08.10
コメントを書く