aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-06-19 14:38:21 +1200
committerTom Ryder <tom@sanctum.geek.nz>2015-06-19 14:38:21 +1200
commitadd8f0fb2d789e230bac318ef74ff61fb996175b (patch)
tree2e1072fb6d0a445ac10a6890b0e01c81c560be2a /bash/bashrc.d
parentAdd missing NAME for getopts (diff)
downloaddotfiles-add8f0fb2d789e230bac318ef74ff61fb996175b.tar.gz
dotfiles-add8f0fb2d789e230bac318ef74ff61fb996175b.zip
Check term has colors before using in gcc
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r--bash/bashrc.d/gcc.bash19
1 files changed, 19 insertions, 0 deletions
diff --git a/bash/bashrc.d/gcc.bash b/bash/bashrc.d/gcc.bash
new file mode 100644
index 00000000..9db34cdc
--- /dev/null
+++ b/bash/bashrc.d/gcc.bash
@@ -0,0 +1,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
+}
+