From c2efcf4ad56efacb02845ed6cbef40f06f85071d Mon Sep 17 00:00:00 2001 From: Daniel K Date: Wed, 19 Mar 2014 08:33:30 +0100 Subject: [PATCH] Escape matched word, Create regex in vim script --- plugin/tmux-complete.vim | 2 +- sh/tmuxwords.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/tmux-complete.vim b/plugin/tmux-complete.vim index 4a39c07..78e0414 100644 --- a/plugin/tmux-complete.vim +++ b/plugin/tmux-complete.vim @@ -10,7 +10,7 @@ function! CompleteScript(findstart, base) endif " find months matching with "a:base" - let command = 'sh ' . shellescape(expand(s:script)) . ' ' . shellescape(a:base) + let command = 'sh ' . shellescape(expand(s:script)) . ' ' . shellescape('^' . escape(a:base, '*^$][.\') . '.') let words = system(command) for word in split(words) call complete_add(word) diff --git a/sh/tmuxwords.sh b/sh/tmuxwords.sh index 6eb594e..4c42923 100644 --- a/sh/tmuxwords.sh +++ b/sh/tmuxwords.sh @@ -19,11 +19,11 @@ grep -v -F "$(tmux display-message -p '11-#{session_id} ')" | cut -d' ' -f2 | # capture panes xargs -n1 tmux capture-pane -J -p -t | -# filter on pattern and append replaced copy -sed -e "/$1./p;s/[^a-zA-Z0-9_]/ /g" | +# copy lines and split words +sed -e 'p;s/[^a-zA-Z0-9_]/ /g' | # split on spaces tr -s '[:space:]' '\n' | # filter out words not beginning with pattern -grep "^$1." | +grep "$1" | # sort and remove duplicates sort -u