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

8
zshrc
View file

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