Skip to content

Commit

Permalink
New menu command: Change selected node permissions (#1348)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkloeckner authored Oct 19, 2023
1 parent d69b68b commit c99395a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions nerdtree_plugin/fs_menu.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit c99395a

Please sign in to comment.