From 741e769580ef673457f8de508470c15cd3092208 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Fri, 8 Jul 2011 12:00:39 +0200 Subject: [PATCH] zshrc: fixing broken any() function (drop usage of expr) bug: try "any -i", "any index", "any length", or anything else that "expr" thinks is a command or option --- etc/zsh/zshrc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 54ce024..996e4e8 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -2875,18 +2875,16 @@ check_com -c qma && alias ?='qma zshall' # grep for running process, like: 'any vim' any() { emulate -L zsh + unsetopt KSH_ARRAYS if [[ -z "$1" ]] ; then echo "any - grep for process(es) by keyword" >&2 echo "Usage: any " >&2 ; return 1 else - local STRING=$1 - local LENGTH=$(expr length $STRING) - local FIRSCHAR=$(echo $(expr substr $STRING 1 1)) - local REST=$(echo $(expr substr $STRING 2 $LENGTH)) - ps xauwww| grep "[$FIRSCHAR]$REST" + ps xauwww | grep --color=auto "[${1[1]}]${1[2,-1]}" fi } + # After resuming from suspend, system is paging heavily, leading to very bad interactivity. # taken from $LINUX-KERNELSOURCE/Documentation/power/swsusp.txt [[ -r /proc/1/maps ]] && \ -- 2.1.4