はじめに
設定ファイルをcat
で見てみて、うーんよみづらいとなってvim -R
で再度開く・・・という手間をかけることが多く困っていたが、
catの表示自体を色付きにできるコマンドがあった。
導入
上記からwgetで取得する
[root@my-instance ~]# cd /tmp
[root@my-instance tmp]# wget https://github.com/owenthereal/ccat/releases/download/v1.1.0/linux-386-1.1.0.tar.gz
--2024-10-13 16:17:33-- https://github.com/owenthereal/ccat/releases/download/v1.1.0/linux-386-1.1.0.tar.gz
Resolving github.com (github.com)... 20.27.177.113
Connecting to github.com (github.com)|20.27.177.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/35140287/63a8cb68-97af-11e5-8a2a-0614b5bf3564?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20241013%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241013T161734Z&X-Amz-Expires=300&X-Amz-Signature=1d14dc8b8f7a66ba84ac3436765a69710625b5524f9f0aca545caa4a1066e41f&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dlinux-386-1.1.0.tar.gz&response-content-type=application%2Foctet-stream [following]
--2024-10-13 16:17:34-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/35140287/63a8cb68-97af-11e5-8a2a-0614b5bf3564?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20241013%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241013T161734Z&X-Amz-Expires=300&X-Amz-Signature=1d14dc8b8f7a66ba84ac3436765a69710625b5524f9f0aca545caa4a1066e41f&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dlinux-386-1.1.0.tar.gz&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.108.133, 185.199.109.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1164672 (1.1M) [application/octet-stream]
Saving to: ‘linux-386-1.1.0.tar.gz’
linux-386-1.1.0.tar.gz 100%[====================================================================================================================>] 1.11M --.-KB/s in 0.009s
2024-10-13 16:17:35 (122 MB/s) - ‘linux-386-1.1.0.tar.gz’ saved [1164672/1164672]
[root@my-instance tmp]# ll
total 1140
-rw-r--r-- 1 root root 1164672 Dec 7 2021 linux-386-1.1.0.tar.gz
drwx------ 3 root root 17 Jul 26 14:29 systemd-private-546f6b0f66ba4e68b7235825a540cde1-chronyd.service-AoYSi1
[root@my-instance tmp]# tar zxvf linux-386-1.1.0.tar.gz
linux-386-1.1.0/
linux-386-1.1.0/ccat
linux-386-1.1.0/LICENSE
linux-386-1.1.0/README.md
[root@my-instance tmp]# ll
total 1140
drwxr-xr-x 2 501 games 50 Dec 1 2015 linux-386-1.1.0
-rw-r--r-- 1 root root 1164672 Dec 7 2021 linux-386-1.1.0.tar.gz
drwx------ 3 root root 17 Jul 26 14:29 systemd-private-546f6b0f66ba4e68b7235825a540cde1-chronyd.service-AoYSi1
[root@my-instance tmp]# cd linux-386-1.1.0/
[root@my-instance linux-386-1.1.0]# ll
total 3500
-rwxr-xr-x 1 501 games 3573376 Dec 1 2015 ccat
-rw-r--r-- 1 501 games 1059 Dec 1 2015 LICENSE
-rw-r--r-- 1 501 games 2366 Dec 1 2015 README.md
PATHが通っているディレクトリに配置
cp -pi ccat /usr/local/bin
[root@my-instance ~]# ll /usr/local/bin
total 3492
-rwxr-xr-x 1 501 games 3573376 Dec 1 2015 ccat
[root@my-instance ~]# which ccat
/usr/local/bin/ccat
catのaliasとしてbash_profileにも記載しておく。
--bg=dark
は背景が黒くなるわけではなく、黒背景に合わせた文字配色にしてくれる、という意図らしい。青字が少し見やすくなった。
[root@my-instance ~]# cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
alias cat='ccat --bg=dark' ★追記
以下のような感じになる。