1
1
Fork 0

zshrc: Check if --color is supported by ls & grep

This commit is contained in:
Jonathan Schleifer 2020-05-26 20:05:20 +00:00
parent 64ae6d36b5
commit 1c7c719fa5

4
zshrc
View file

@ -49,16 +49,20 @@ if [ -n "$grep" -o -n "$grep_color" ]; then
: ${grep:=$(__find_command ggrep grep)}
[ -n "$grep_color" -a "$grep_color[1]" != - ] &&
grep_color="--color=$grep_color"
if echo x | $grep $grep_color x &>/dev/null; then
alias grep="$grep $grep_color"
fi
fi
alias fgrep="grep -F"
if [ -n "$ls" -o -n "$ls_color" ]; then
: ${ls:=$(__find_command gls ls)}
[ -n "$ls_color" -a "$ls_color[1]" != - ] &&
ls_color="--color=$ls_color"
if $ls $ls_color &>/dev/null; then
alias ls="$ls $ls_color"
fi
fi
[ "$ls_on_cd" = yes ] && chpwd() { ls }
[ "$ls_on_init" = yes ] && ls