shownotes-w3m-rice/mlocate_vdiscover_vim_locate.txt

45 lines
1.5 KiB
Plaintext
Raw Normal View History

2013-05-25 00:51:04 +00:00
# this is notes for video: http://www.youtube.com/watch?v=X0KPl5O006M
-------------------------------
## for ~/.bashrc or ~/.zshrc
vdiscover() {
2013-05-25 17:59:34 +00:00
# demo video: http://www.youtube.com/watch?v=X0KPl5O006M
2013-05-25 00:51:04 +00:00
# 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)$'
2013-05-25 17:59:34 +00:00
# vdiscover naruto shippudden mkv$
# to quit vim quickly use: shift + zz or u can always use the :q / :q! method
2013-05-25 00:51:04 +00:00
# escape spaces, pipe and parentheses
2013-05-25 17:59:34 +00:00
keyword=$(echo "$@" | sed -e 's/ /.*/g' -e 's:|:\\|:g' -e 's:(:\\(:g' -e 's:):\\):g')
2013-05-25 00:51:04 +00:00
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>