diff options
author | Florian Pritz <bluewind@xssn.at> | 2010-04-11 17:01:12 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xssn.at> | 2010-04-11 17:01:12 +0200 |
commit | 706da08ee1fa293ad6e2dc328e016b2d00e234e2 (patch) | |
tree | cd89bc862b4a4a0f1986aa474a0e8601da161abc | |
parent | c548088e6652f1be24ef01a65e429a0fa03ec8d8 (diff) | |
download | dotfiles-706da08ee1fa293ad6e2dc328e016b2d00e234e2.tar.gz dotfiles-706da08ee1fa293ad6e2dc328e016b2d00e234e2.tar.xz |
zshrc: add regcheck
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-rw-r--r-- | .zshrc | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -429,6 +429,25 @@ __chrootshell() { sudo umount "$chrootdir/union-shell" } +# source: http://github.com/trapd00r/configs/blob/master/.zsh/functions.zsh +regcheck() { + if [[ -z $1 ]] || [[ -z $2 ]] || [[ $1 = "-h" ]]; then + echo -e "${blue}Usage:$NC regcheck <regexp> <string>"; + return 1 + fi + + emulate -L zsh + zmodload -i zsh/pcre + pcre_compile $1 && \ + if pcre_match $2; then + echo -e "${green}matches$NC" + return 0 + else + echo "${red}no match$NC" + return 1 + fi +} + # }}} # History {{{ export HISTFILE=~/.zsh/histfile |