1 " ============================================================================
2 " File: exec_menuitem.vim
3 " Description: plugin for NERD Tree that provides an execute file menu item
4 " Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
5 " Last Change: 22 July, 2009
6 " License: This program is free software. It comes without any warranty,
7 " to the extent permitted by applicable law. You can redistribute
8 " it and/or modify it under the terms of the Do What The Fuck You
9 " Want To Public License, Version 2, as published by Sam Hocevar.
10 " See http://sam.zoy.org/wtfpl/COPYING for more details.
12 " ============================================================================
13 if exists("g:loaded_nerdtree_exec_menuitem")
16 let g:loaded_nerdtree_exec_menuitem = 1
18 call NERDTreeAddMenuItem({
19 \ 'text': '(!)Execute file',
21 \ 'callback': 'NERDTreeExecFile',
22 \ 'isActiveCallback': 'NERDTreeExecFileActive' })
24 function! NERDTreeExecFileActive()
25 let node = g:NERDTreeFileNode.GetSelected()
26 return !node.path.isDirectory && node.path.isExecutable
29 function! NERDTreeExecFile()
30 let treenode = g:NERDTreeFileNode.GetSelected()
31 echo "==========================================================\n"
32 echo "Complete the command to execute (add arguments etc):\n"
33 let cmd = treenode.path.str({'escape': 1})
34 let cmd = input(':!', cmd . ' ')