mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-22 15:18:23 +08:00
New menu command: Run a system command in this directory. (#1214)
* New menu command: Run system command in this directory. * Echo the output from the system command. * Update version number in change log. * Address Vim linter message: change "\n" to nr2char(10) * Use single quoted strings. * Use system() instead of systemlist() for greater version compatibility. systemlist() was introduced sometime in Vim 8+, so I switched to system() for 7.4 compatibility.
This commit is contained in:
parent
628098fff1
commit
c8be9458dd
|
@ -5,6 +5,7 @@
|
||||||
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
|
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
|
||||||
-->
|
-->
|
||||||
#### 6.10
|
#### 6.10
|
||||||
|
- **.2**: New menu command: Run a system command in this directory. (PhilRunninger) [#1214](https://github.com/preservim/nerdtree/pull/1214)
|
||||||
- **.1**: Escape quotation marks so they can be used in key mappings. (PhilRunninger) [#1213](https://github.com/preservim/nerdtree/pull/1213)
|
- **.1**: Escape quotation marks so they can be used in key mappings. (PhilRunninger) [#1213](https://github.com/preservim/nerdtree/pull/1213)
|
||||||
- **.0**: Enable full path specifications for NERDTreeIgnore (PhilRunninger) [#1207](https://github.com/preservim/nerdtree/pull/1207)
|
- **.0**: Enable full path specifications for NERDTreeIgnore (PhilRunninger) [#1207](https://github.com/preservim/nerdtree/pull/1207)
|
||||||
#### 6.9
|
#### 6.9
|
||||||
|
|
|
@ -49,6 +49,10 @@ else
|
||||||
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'})
|
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'})
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if exists('*system')
|
||||||
|
call NERDTreeAddMenuItem({'text': 'Run (s)ystem command in this directory', 'shortcut':'s', 'callback': 'NERDTreeSystemCommand'})
|
||||||
|
endif
|
||||||
|
|
||||||
"FUNCTION: s:inputPrompt(action){{{1
|
"FUNCTION: s:inputPrompt(action){{{1
|
||||||
"returns the string that should be prompted to the user for the given action
|
"returns the string that should be prompted to the user for the given action
|
||||||
"
|
"
|
||||||
|
@ -460,4 +464,21 @@ function! NERDTreeExecuteFileWindows()
|
||||||
call system('cmd.exe /c start "" ' . shellescape(l:node.path.str()))
|
call system('cmd.exe /c start "" ' . shellescape(l:node.path.str()))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: NERDTreeSystemCommand() {{{1
|
||||||
|
function! NERDTreeSystemCommand()
|
||||||
|
let l:node = g:NERDTreeFileNode.GetSelected()
|
||||||
|
|
||||||
|
if empty(l:node)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:cwd = getcwd()
|
||||||
|
let l:directory = l:node.path.isDirectory ? l:node.path.str() : l:node.parent.path.str()
|
||||||
|
execute 'cd '.l:directory
|
||||||
|
|
||||||
|
let l:nl = nr2char(10)
|
||||||
|
echo l:nl . system(input(l:directory . (nerdtree#runningWindows() ? '> ' : ' $ ')))
|
||||||
|
execute 'cd '.l:cwd
|
||||||
|
endfunction
|
||||||
|
|
||||||
" vim: set sw=4 sts=4 et fdm=marker:
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user