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,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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue