You could make the command asynchronous by wrapping it in something like: { ... } &>/dev/null &
Yep, that works great. But I had to add a "cat - | " to the beginning to pass stdin. Here is the finished command:
cat - | { if [ -f /tmp/tm_saved_regex ]; then REGEX="`cat /tmp/tm_saved_regex`"; else REGEX="^\s*\w+.*$"; fi
res=$(CocoaDialog inputbox \ --title "Find matching lines" \ --informative-text "Regular expression to match lines:" \ --text "$REGEX" \ --button1 "Find" --button2 "Cancel") [[ $(head -n1 <<<"$res") == "2" ]] && exit_discard REGEX=$(tail -n1 <<<"$res");
echo "$REGEX" > /tmp/tm_saved_regex;
TMP="$(mktemp /tmp/tm_findmatchinglines_XXXXXXXX).${TM_FILENAME##*.}"; perl -ne "print if /$REGEX/" > "$TMP"; mate "$TMP" } &>/dev/null &
Q