grep.kak: configurable grep command, search selection when no params

This commit is contained in:
Maxime Coste 2012-12-06 20:26:23 +01:00
parent c000ca2220
commit d25bafa95d

View File

@ -1,8 +1,14 @@
setg grepcmd 'grep -RHn'
def -shell-params -file-completion \
grep %{ %sh{
output=$(mktemp -d -t kak-grep.XXXXXXXX)/fifo
mkfifo ${output}
( grep -PHn "$@" >& ${output} ) >& /dev/null < /dev/null &
if (( $# > 0 )); then
( ${kak_opt_grepcmd} "$@" >& ${output} ) >& /dev/null < /dev/null &
else
( ${kak_opt_grepcmd} "${kak_selection}" >& ${output} ) >& /dev/null < /dev/null &
fi
echo "try %{ db *grep* } catch %{ }
edit -fifo ${output} *grep*
setb filetype grep
@ -16,4 +22,4 @@ hook global WinSetOption filetype=grep %{
hook global WinSetOption filetype=(?!grep).* %{ rmhl grep-highlight; }
def gjump %{ exec 'xs^([^:]+):(\d+)<ret>'; edit %reg{1} %reg{2} }
def jump %{ exec 'xs^([^:]+):(\d+):(\d+)?<ret>'; edit %reg{1} %reg{2} %reg{3} }