" ============================================================================
" File: execute_menuitem.vim
" Description: plugin for NERD Tree that provides an execute menu item, that
" executes system default application for file or directory
" ============================================================================
if exists("g:loaded_nerdtree_shell_exec_menuitem")
finish
endif
let g:loaded_nerdtree_shell_exec_menuitem = 1
let g:haskdeinit = system("ps -e") =~ 'kdeinit'
call NERDTreeAddMenuItem({
\ 'text': 'e(x)ecute',
\ 'shortcut': 'x',
\ 'callback': 'NERDTreeExecute' })
function! NERDTreeExecute()
let treenode = g:NERDTreeFileNode.GetSelected()
let path = treenode.path.str()
if has("unix") && executable("gnome-open") && !g:haskdeinit
exe "silent !gnome-open ".shellescape(path,1)." > /dev/null"
let ret= v:shell_error
elseif has("unix") && executable("kfmclient") && g:haskdeinit
exec "silent !kfmclient exec ".shellescape(path,1)." > /dev/null"
let ret= v:shell_error
end
redraw!
endfunction
Source: https://habr.com/ru/post/94758/
All Articles