summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-04-11 17:01:12 +0200
committerFlorian Pritz <bluewind@xssn.at>2010-04-11 17:01:12 +0200
commit706da08ee1fa293ad6e2dc328e016b2d00e234e2 (patch)
treecd89bc862b4a4a0f1986aa474a0e8601da161abc
parentc548088e6652f1be24ef01a65e429a0fa03ec8d8 (diff)
downloaddotfiles-706da08ee1fa293ad6e2dc328e016b2d00e234e2.tar.gz
dotfiles-706da08ee1fa293ad6e2dc328e016b2d00e234e2.tar.xz
zshrc: add regcheck
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-rw-r--r--.zshrc19
1 files changed, 19 insertions, 0 deletions
diff --git a/.zshrc b/.zshrc
index 54ad658..0bd9324 100644
--- a/.zshrc
+++ b/.zshrc
@@ -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