给make加上颜色

编译打包和其他
回复
tusooa
帖子: 6548
注册时间: 2008-10-31 22:12
系统: 践兔
联系:

给make加上颜色

#1

帖子 tusooa » 2010-07-28 18:43

ps:如果发错版了请版主移动。
包:Make+colors
依赖: GNU/Linux, 下载工具, 网页浏览器
( :em04 不要apt阿,apt不到的)

闻GoboLinux有一ColorMake,将make的东西分不同内容用不同颜色显示。可惜系统不是GoboLinux,将ColorMake复制到其他GNU/Linux上。于是纂此文。

1:把源码搞到手。

GoboLinux的Scripts的svn地址为:http://svn.gobolinux.org/tools/trunk/Scripts

于是检出:

代码: 全选

cd ~/个人/下载/VCS/SVN-Download &&
svn co http://svn.gobolinux.org/tools/trunk/Scripts
ColorMake依赖Mtail,源码地址:http://matt.immute.net/src/mtail/mtail-1.1.1.tgz

2:Mtail
依赖: Python

代码: 全选

tlcr: 0 庚寅年六月十七日 16:59:39 ~
>> file ~scripts/mtail
/home/tusooa/应用/脚本/mtail: a /usr/bin/python script text executable
笨兔里面是预装的。
安装Mtail:

代码: 全选

cp mtail $HOME/应用/脚本/
3:ColorMake & ColorMake.mtailrc

代码: 全选

tlcr: 0 庚寅年六月十七日 16:59:53 ~
>> dog ~dw/VCS/SVN-Download/Scripts/bin/ColorMake
#!/bin/bash

. ScriptFunctions
Import File
Import GoboLinux

# XXX "Real vs. rootless" support
if [ -x /bin/make ]
then makecmd=/bin/make
elif [ -x /usr/bin/make ]
then makecmd=/usr/bin/make
fi

for i in "$@"
do
    if [ "$i" = "menuconfig" ]
    then exec $makecmd "$@"
    fi
done

if Quiet which mtail; then
   $makecmd "$@" 2>&1 | mtail --config="`Find_Conf ColorMake.mtailrc`" -q
   exit ${PIPESTATUS[0]}
else
   Log_Terse "mtail not found. Unable to colorize output."
   $makecmd "$@"
fi
tlcr: 0 庚寅年六月十七日 17:04:30 ~
>> 
里面提到一个ColorMake.mtailrc,就是要cp的配置文件

Scripts里面的那个ColorMake是给GoboLinux用的,在其他的GNU/Linux里面貌似不能用,所以只要那个配置文件。ColorMake待会儿自己写。

拷贝配置文件:

代码: 全选

cp Resources/Defaults/Settings/Scripts/ColorMake.mtailrc ~/应用/配置/
ColorMake(依赖:Bash-Libraries):

代码: 全选

tlcr: 0 庚寅年六月十七日 17:42:57 ~
>> ds-打印脚本.bash ColorMake   
#!/bin/bash
# vim : ft=bash

. scriptFunctions

if [ "$(no-err which make)" ] ; then
    makeCmd="$(which make)"
else
    dieg $Ec_FileNotFound "没有找到 make"
fi

args=()
while [[ $# > 0 ]] ; do
    if [[ "$1" == "-N" ]] || [[ "$1" == "--no-colors" ]] ; then
        shift
        "$makeCmd" "${args[@]}" "$@"
        exit
    else
        args=("${args[@]}" "$1")
    fi
    shift
done

if quiet which mtail ; then
    "$makeCmd" "${args[@]}" 2>&1 | mtail --config "$HOME/应用/配置/ColorMake.mtailrc" -q
else
    "$makeCmd" "${args[@]}"
fi
tlcr: 0 庚寅年六月十七日 17:42:58 ~
>> 
用ColorMake -N来关闭颜色.
输入make的时候自动加colors:
以下内容,拷贝到~/.zshrc的最后:

代码: 全选

alias make=ColorMake

代码: 全选

] ls -ld //
头像
qiang_liu8183
论坛版主
帖子: 10701
注册时间: 2006-09-10 22:36
系统: Arch Debian
来自: 北京

Re: 给make加上颜色

#2

帖子 qiang_liu8183 » 2010-07-29 1:38

好久没见技术帖了
干不了大事就把小事干的大气点
回复