zshrc: Check if --color is supported by ls & grep
This commit is contained in:
parent
64ae6d36b5
commit
1c7c719fa5
1 changed files with 6 additions and 2 deletions
4
zshrc
4
zshrc
|
@ -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"
|
||||||
|
if echo x | $grep $grep_color x &>/dev/null; then
|
||||||
alias grep="$grep $grep_color"
|
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"
|
||||||
|
if $ls $ls_color &>/dev/null; then
|
||||||
alias ls="$ls $ls_color"
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue