You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shownotes-w3m-rice/mlocate_vdiscover_vim_locat...

45 lines
1.5 KiB
Plaintext

# 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>