From 443f2ef0e5f6abd6dbfa78fdd45fe3ab0ab797b9 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sun, 19 Jul 2015 16:44:47 +0200 Subject: [PATCH] New plugin "grep" This plugin is a default plugin, therefore loaded automatically. --- ax.zsh | 1 + plugins/grep/grep.zshrc | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 plugins/grep/grep.zshrc diff --git a/ax.zsh b/ax.zsh index d061aea..072adf5 100644 --- a/ax.zsh +++ b/ax.zsh @@ -69,6 +69,7 @@ if ! typeset +m axzsh_default_plugins | fgrep array >/dev/null 2>&1; then axzsh_default_plugins=( byebye correction + grep history less ls diff --git a/plugins/grep/grep.zshrc b/plugins/grep/grep.zshrc new file mode 100644 index 0000000..f83468a --- /dev/null +++ b/plugins/grep/grep.zshrc @@ -0,0 +1,30 @@ +# AX-ZSH: Alex' Modular ZSH Configuration +# grep.zshrc: Setup grep + +# Make sure that "grep(1)" is installed +(( $+commands[grep] )) || return + +grep-flag-available() { + echo | grep "$1" "" >/dev/null 2>&1 +} + +grep_options="" +vcs_folders="{.bzr,.cvs,.git,.hg,.svn}" + +# Color +if grep-flag-available "--color=auto"; then + grep_options+=" --color=auto" +fi + +# Exclude VCS folders +if grep-flag-available "--exclude-dir=.csv"; then + grep_options+=" --exclude-dir=$vcs_folders" +elif grep-flag-available "--exclude=.csv"; then + grep_options+=" --exclude=$vcs_folders" +fi + +[[ -n "$options" ]] && alias grep="grep${grep_options}" + +unfunction grep-flag-available +unset grep_options +unset vcs_folders -- 2.39.2