]> arthur.barton.de Git - ax-zsh.git/blob - plugins/grep/grep.zshrc
New plugin "grep"
[ax-zsh.git] / plugins / grep / grep.zshrc
1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # grep.zshrc: Setup grep
3
4 # Make sure that "grep(1)" is installed
5 (( $+commands[grep] )) || return
6
7 grep-flag-available() {
8         echo | grep "$1" "" >/dev/null 2>&1
9 }
10
11 grep_options=""
12 vcs_folders="{.bzr,.cvs,.git,.hg,.svn}"
13
14 # Color
15 if grep-flag-available "--color=auto"; then
16         grep_options+=" --color=auto"
17 fi
18
19 # Exclude VCS folders
20 if grep-flag-available "--exclude-dir=.csv"; then
21         grep_options+=" --exclude-dir=$vcs_folders"
22 elif grep-flag-available "--exclude=.csv"; then
23         grep_options+=" --exclude=$vcs_folders"
24 fi
25
26 [[ -n "$options" ]] && alias grep="grep${grep_options}"
27
28 unfunction grep-flag-available
29 unset grep_options
30 unset vcs_folders