From 6ccf83df24ac3044117e10b99be43d00923dbeea Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Mon, 15 Sep 2014 11:14:44 -0400 Subject: [PATCH 1/4] Add menu option to display file/directory properties. --- nerdtree_plugin/fs_menu.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 4e03f35..e944709 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -23,6 +23,7 @@ endif call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) +call NERDTreeAddMenuItem({'text': 'show (p)roperties of the current node', 'shortcut': 'p', 'callback': 'NERDTreeNodeProperties'}) if has("gui_mac") || has("gui_macvim") call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) @@ -206,6 +207,12 @@ function! NERDTreeDeleteNode() endfunction +" FUNCTION: NERDTreeNodeProperties() {{{1 +function! NERDTreeNodeProperties() + let currentNode = g:NERDTreeFileNode.GetSelected() + call s:echo(getfsize(currentNode.path.str())." bytes modified on ".strftime("%A %Y-%m-%d %H:%M:%S", getftime(currentNode.path.str()))) +endfunction + " FUNCTION: NERDTreeCopyNode() {{{1 function! NERDTreeCopyNode() let currentNode = g:NERDTreeFileNode.GetSelected() From c60f40137170fe9685b15467b53276179cea0fc9 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 12 Nov 2015 16:20:20 -0500 Subject: [PATCH 2/4] Merge (p)roperties (for Windows) into the (l)ist menu item. --- nerdtree_plugin/fs_menu.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index db729b4..c26255f 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -37,6 +37,8 @@ endif if has("unix") || has("osx") call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'}) +else + call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) endif "FUNCTION: s:echo(msg){{{1 @@ -212,8 +214,8 @@ function! NERDTreeDeleteNode() endfunction -" FUNCTION: NERDTreeNodeProperties() {{{1 -function! NERDTreeNodeProperties() +" FUNCTION: NERDTreeListNodeWin32() {{{1 +function! NERDTreeListNodeWin32 let currentNode = g:NERDTreeFileNode.GetSelected() call s:echo(getfsize(currentNode.path.str())." bytes modified on ".strftime("%A %Y-%m-%d %H:%M:%S", getftime(currentNode.path.str()))) endfunction From f1af61ddf722132401898daadb833aead09afeb2 Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 12 Nov 2015 21:29:34 -0500 Subject: [PATCH 3/4] Use the system('DIR /Q...') function to display file info. --- nerdtree_plugin/fs_menu.vim | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index c26255f..2a6ddd6 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -23,7 +23,6 @@ endif call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) -call NERDTreeAddMenuItem({'text': 'show (p)roperties of the current node', 'shortcut': 'p', 'callback': 'NERDTreeNodeProperties'}) if has("gui_mac") || has("gui_macvim") || has("mac") call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) @@ -215,9 +214,15 @@ function! NERDTreeDeleteNode() endfunction " FUNCTION: NERDTreeListNodeWin32() {{{1 -function! NERDTreeListNodeWin32 - let currentNode = g:NERDTreeFileNode.GetSelected() - call s:echo(getfsize(currentNode.path.str())." bytes modified on ".strftime("%A %Y-%m-%d %H:%M:%S", getftime(currentNode.path.str()))) +function! NERDTreeListNodeWin32() + let treenode = g:NERDTreeFileNode.GetSelected() + if treenode != {} + let metadata = split(system('dir /q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n') + call s:echo(metadata[0]) + else + call s:echo("No information avaialable") + endif + endfunction " FUNCTION: NERDTreeCopyNode() {{{1 @@ -259,6 +264,7 @@ function! NERDTreeCopyNode() redraw endfunction +" FUNCTION: NERDTreeQuickLook() {{{1 function! NERDTreeQuickLook() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} @@ -266,6 +272,7 @@ function! NERDTreeQuickLook() endif endfunction +" FUNCTION: NERDTreeRevealInFinder() {{{1 function! NERDTreeRevealInFinder() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} @@ -273,6 +280,7 @@ function! NERDTreeRevealInFinder() endif endfunction +" FUNCTION: NERDTreeExecuteFile() {{{1 function! NERDTreeExecuteFile() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} @@ -280,6 +288,7 @@ function! NERDTreeExecuteFile() endif endfunction +" FUNCTION: NERDTreeListNode() {{{1 function! NERDTreeListNode() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} From 3fb18e7399156195bf1e91845ca1da801632967e Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Thu, 12 Nov 2015 21:38:22 -0500 Subject: [PATCH 4/4] Switch to upper case DIR /Q, in true DOS fashion --- nerdtree_plugin/fs_menu.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim index 2a6ddd6..043e337 100644 --- a/nerdtree_plugin/fs_menu.vim +++ b/nerdtree_plugin/fs_menu.vim @@ -217,7 +217,7 @@ endfunction function! NERDTreeListNodeWin32() let treenode = g:NERDTreeFileNode.GetSelected() if treenode != {} - let metadata = split(system('dir /q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n') + let metadata = split(system('DIR /Q ' . shellescape(treenode.path.str()) . ' | FINDSTR "^[012][0-9]/[0-3][0-9]/[12][0-9][0-9][0-9]"'), '\n') call s:echo(metadata[0]) else call s:echo("No information avaialable")