diff --git a/plugins/colorgcc/colorgcc.plugin.zsh b/plugins/colorgcc/colorgcc.plugin.zsh new file mode 100644 index 0000000..a57101b --- /dev/null +++ b/plugins/colorgcc/colorgcc.plugin.zsh @@ -0,0 +1,51 @@ +#!/bin/zsh + +# This file is part of xals' zsh utils. +# +# xals' zsh utils is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# xals' zsh utils is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with xals' zsh utils. If not, see +# . + +function _colorgcc_plugin_gen_colorgccrc() { + local _colorgcc_plugin_colorgccrc + zstyle -s :xals:plugins:colorgcc colorgccrc _colorgcc_plugin_colorgccrc + + cat > ${_colorgcc_plugin_colorgccrc:="${HOME}/.colorgccrc"} << EOF +g++: ${_colorgcc_plugin_gcc_path}/g++ +gcc: ${_colorgcc_plugin_gcc_path}/gcc +c++: ${_colorgcc_plugin_gcc_path}/g++ +cc: ${_colorgcc_plugin_gcc_path}/gcc +g77: /usr/bin/g77 +f77: /usr/bin/g77 +gcj: /usr/bin/gcj +EOF +} + +if [ -x "/usr/lib/colorgcc/bin" ]; then + local -x _colorgcc_plugin_gcc_path + + if [ -x "/usr/lib/ccache/bin" ]; then + # Keep compatibility with ccache + export CCACHE_PATH="/usr/bin" + + _colorgcc_plugin_gcc_path="/usr/lib/ccache/bin" + else + # Prepend colorgcc path + export PATH="/usr/lib/colorgcc/bin:$PATH" + + _colorgcc_plugin_gcc_path="/usr/bin" + fi + + _colorgcc_plugin_gen_colorgccrc +fi +