【bash】素lsとperlしかない環境で、lsコマンドの結果を色付き表示する
PleiadesをDLしている合間に……
概要
タイトルの通りです。[colorls.sh]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
Usage(){ | |
cat << __EOT__ >&2 | |
lsコマンドの実行結果を色付きで表示します | |
Usage:`basename $0` <各種lsコマンドのオプション> | |
使用例) $ `basename $0` | |
__EOT__ | |
} | |
# 引数エラーチェック | |
if [ "$1" = "--help" ] ; then | |
Usage | |
exit 1 | |
fi | |
# -------------------------------------------------- | |
\ls -F $* | perl -pe " | |
s/(\S+)\/( |\Z)$/\033[35;1m\1\033[m\/\2/g ; | |
s/(\S+)\*( |\Z)$/\033[36m\1\033[m*\2/g ; | |
s/(\S+)( \-> |@)$/\033[31m\1\2\033[m/g | |
" |
……そろそろPleiadesのDL終わったかな。