From 3edecc2e6d659bebdf74c7d5734d1c8357f76af2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 15 May 2012 14:28:02 +1200 Subject: Slightly more elegant grep/ls colouring Mostly just improving the readability of the conditional logic a bit. --- bash/bashrc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/bashrc b/bash/bashrc index 0f280084..169c6690 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -37,11 +37,13 @@ PS1='\u@\h:\w\$ ' PS2='...' # Use colors for ls and grep, if available. -if hash dircolors &>/dev/null; then +if ls --help | grep -q -- --color && hash dircolors &>/dev/null; then eval "$(dircolors -b)" - ls --help | grep -q -- --color && alias ls='ls --color=auto' + alias ls='ls --color=auto' +fi +if grep --help | grep -q -- --color; then + alias grep='grep --color=auto' fi -grep --help | grep -q -- --color && alias grep='grep --color=auto' # Use completion, if available. if [ -e /etc/bash_completion ]; then -- cgit v1.2.3