aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/gcc.bash
blob: 9db34cdc799b092cb7e4ffbf56728222bf2817d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Define function wrapper for gcc(1) with --color option if GCC_COLORS is set;
# checks that color is available in the terminal within the function
if [[ ! -n $GCC_COLORS ]] ; then
    return
fi

# Define function proper
gcc() {
    local -i colors
    colors=$( {
        tput Co || tput colors
    } 2>/dev/null )
    if ((colors >= 8)) ; then
        command gcc --color=auto "$@"
    else
        command gcc "$@"
    fi
}