From 73fc1ba943ffdf4e304d3514c8f2f783be4ec42b Mon Sep 17 00:00:00 2001 From: gotbletu Date: Sat, 25 May 2013 10:59:34 -0700 Subject: [PATCH] i learn sed --- mlocate_vdiscover_vim_locate.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mlocate_vdiscover_vim_locate.txt b/mlocate_vdiscover_vim_locate.txt index 6ce94ca..67b59c1 100644 --- a/mlocate_vdiscover_vim_locate.txt +++ b/mlocate_vdiscover_vim_locate.txt @@ -4,14 +4,18 @@ ------------------------------- ## for ~/.bashrc or ~/.zshrc vdiscover() { + # demo video: http://www.youtube.com/watch?v=X0KPl5O006M # usage: vdiscover # example: vdiscover man vs wild # OR operator: vdiscover 'man vs wild (mkv|avi)' # $ ending in: vdiscover 'man vs wild (mkv|avi)$' # vdiscover '(naruto|shingeki) (mkv|avi)$' + # vdiscover naruto shippudden mkv$ + + # to quit vim quickly use: shift + zz or u can always use the :q / :q! method # escape spaces, pipe and parentheses - keyword=$(echo "$@" | sed 's/ /.*/g' | sed 's:|:\\|:g' | sed 's:(:\\(:g' | sed 's:):\\):g') + keyword=$(echo "$@" | sed -e 's/ /.*/g' -e 's:|:\\|:g' -e 's:(:\\(:g' -e 's:):\\):g') locate -ir "$keyword" | vim -R - }