New menu command: Change selected node permissions (#1348)

This commit is contained in:
Martin J. Klöckner 2023-10-19 09:33:38 -03:00 committed by GitHub
parent d69b68bf31
commit c99395a323
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,6 +45,7 @@ call NERDTreeAddMenuItem({'text': (has('clipboard')?'copy (p)ath to clipboard':'
if has('unix') || has('osx')
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'})
call NERDTreeAddMenuItem({'text': '(C)hange node permissions', 'shortcut':'C', 'callback': 'NERDTreeChangePermissions'})
else
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'})
endif
@ -333,6 +334,29 @@ function! NERDTreeListNodeWin32()
call nerdtree#echo('node not recognized')
endfunction
" FUNCTION: NERDTreeChangePermissions() {{{1
function! NERDTreeChangePermissions()
let l:node = g:NERDTreeFileNode.GetSelected()
let l:prompt = "change node permissions: "
let l:newNodePerm = input(l:prompt)
if !empty(l:node)
let l:path = l:node.path.str()
let l:cmd = 'chmod ' .. newNodePerm .. ' ' .. path
let l:error = split(system(l:cmd), '\n')
if !empty(l:error)
call nerdtree#echo(l:error[0])
endif
call b:NERDTree.root.refresh()
call b:NERDTree.render()
return
endif
call nerdtree#echo('node not recognized')
endfunction
" FUNCTION: NERDTreeCopyNode() {{{1
function! NERDTreeCopyNode()
let currentNode = g:NERDTreeFileNode.GetSelected()