Last active
December 17, 2015 12:49
-
-
Save kunst1080/5612280 to your computer and use it in GitHub Desktop.
素lsとperlしかない環境で、lsコマンドの結果を色付き表示する
This file contains 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 | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment