forked from gotbletu/shownotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mlocate_vdiscover_vim_locate.txt
44 lines (34 loc) · 1.49 KB
/
mlocate_vdiscover_vim_locate.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# this is notes for video: http://www.youtube.com/watch?v=X0KPl5O006M
-------------------------------
## for ~/.bashrc or ~/.zshrc
vdiscover() {
# demo video: http://www.youtube.com/watch?v=X0KPl5O006M
# usage: vdiscover <search>
# 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 -e 's/ /.*/g' -e 's:|:\\|:g' -e 's:(:\\(:g' -e 's:):\\):g')
locate -ir "$keyword" | vim -R -
}
-------------------------------
# for ~/.vimrc
" credits
" http://vim.wikia.com/wiki/Open_a_web-browser_with_the_URL_in_the_current_line
" section 41.6 using functions http://vimdoc.sourceforge.net/htmldoc/usr_41.html
" devnull https://code.google.com/p/vimwiki/issues/detail?id=401
" put qoutes around line http://stackoverflow.com/a/3218805
" bypass pressing Enter to continue with extra <CR> http://stackoverflow.com/a/890831
function! OpenCurrentLine ()
" grab current line
let line = getline (".")
" add qoutes around the current line to avoid spaces/symbols issues
let line = substitute(line, '^\(.*\)$', '"\1"', "g")
" open with default system app, no messy output msg
exec "!xdg-open" line '>&/dev/null &'
endfunction
"bind function to a hotkey
map <F8> :call OpenCurrentLine() <CR><CR>