Commit c310597d authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm search: optimize grep when search for one word, apply short option before…

epm search: optimize grep when search for one word, apply short option before all, disable localized description Signed-off-by: Vitaly Lipatov's avatarVitaly Lipatov <lav@etersoft.ru>
parent 7c7da495
...@@ -96,7 +96,7 @@ case $PMTYPE in ...@@ -96,7 +96,7 @@ case $PMTYPE in
;; ;;
esac esac
docmd $CMD $string LANG=C docmd $CMD $string
} }
# TODO: use ^ as first word, use ~ for negate, for epmqp too # TODO: use ^ as first word, use ~ for negate, for epmqp too
...@@ -123,22 +123,28 @@ __epm_search_make_grep() ...@@ -123,22 +123,28 @@ __epm_search_make_grep()
#list=$(strip_spaces $list | sed -e "s/ /|/g") #list=$(strip_spaces $list | sed -e "s/ /|/g")
listN=$(strip_spaces $listN | sed -e "s/ /|/g" | sed -e "s/\^//g") listN=$(strip_spaces $listN | sed -e "s/ /|/g" | sed -e "s/\^//g")
if [ "$short" ] ; then
echon " | sed -e \"s| .*||g\""
fi
[ -n "$listN" ] && echon " | egrep -i -v -- \"$listN\"" [ -n "$listN" ] && echon " | egrep -i -v -- \"$listN\""
# FIXME: The World has not idea how to do grep both string # FIXME: The World has not idea how to do grep both string
# http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1 # http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1
for i in $list ; do
# FIXME -n on MacOS?
echon " | egrep -i -- \"$i\""
done
if [ "$short" ] ; then # Need only if we have more than one word (with one word we will grep for colorify)
echon " | sed -e \"s| .*||g\"" if [ "$(echo "$list" | wc -w)" -gt 1 ] ; then
for i in $list ; do
# FIXME -n on MacOS?
echon " | egrep -i -- \"$i\""
done
fi fi
# FIXME: move from it # FIXME: move from it
#isatty || return #isatty || return
# TODO: sorts word by length from large to short
local COLO="" local COLO=""
# rule for colorife # rule for colorife
for i in $list $listN; do for i in $list $listN; do
...@@ -146,6 +152,7 @@ __epm_search_make_grep() ...@@ -146,6 +152,7 @@ __epm_search_make_grep()
COLO="$COLO$i" COLO="$COLO$i"
done done
# TODO: use some colorifer instead grep (check grep adove too)
if [ -n "$list" ] ; then if [ -n "$list" ] ; then
echon " | egrep -i $EGREPCOLOR -- \"($COLO)\"" echon " | egrep -i $EGREPCOLOR -- \"($COLO)\""
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment