From 3a1d340f2ddd0af6e741731c10d6a66df6bb05e2 Mon Sep 17 00:00:00 2001 From: Amber Date: Mon, 5 Feb 2024 14:03:44 +0100 Subject: [PATCH] guide to command --- README.md | 36 ++++++++++++++++++++++++++++++++---- src/tree_find.py | 10 +--------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 2c67c2b..b52a20f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,33 @@ -# Nerd tree +# Visual Find + +**vfind** is a tool written in python based on *nerd_tree*.
+Its purpose (and base idea) is to blend the unix command *find* with the *tree* command.
+You can search in a particular subtree for files or folders that match a regular expression and other criteria, the results will be shown graphically in a tree (in a similar way that the tree command does).
+ +## Installation on your system + +In my opinion the better solution is:
+1. Clone the repository in your home folder +2. Go to your home folder and make a symbolic link to the command, in your ~/bin folder +``` + cd ~/nerd_tree + ln -s ~/nerd_tree/vfind.py ~/bin/vfind +``` + +## How to use + +**vfind** has 2 mandatory arguments, the *path* of subtree from which to begin the search and the *search* pattern (a regexp) + +``` +vfind ~/nerd_tree/ "(.*)rem(.*)" +``` + +all items matching the pattern are show in the result tree.
+The folder matching the pattern are show with information about the total number of files and the size of the subtree. +If you want to show the subtree expanded you can use the flag **-s** + +``` +vfind ~/nerd_tree/ "(.*)rem(.*)" -s +``` + -An ugly version of the unix-like tree command and a visual version of find command that shows the results found in a visual tree. -All written in python language. -Branch is unstable and under development diff --git a/src/tree_find.py b/src/tree_find.py index 165189b..356eb6b 100644 --- a/src/tree_find.py +++ b/src/tree_find.py @@ -29,8 +29,6 @@ class NerdTreeFind(NerdTree): return all([test_match, test_type]) def find_node_recursively(self, node): - # if node['name'] == self.item_name: - # if self.re_item_name.match(node['name']): if self.found_true_cond(node): node_copy = node.copy() node_copy.update({'color_formatter' : YELLOW, 'found' : 1}) @@ -42,8 +40,6 @@ class NerdTreeFind(NerdTree): if item_child['type'] == 'd': self.find_node_recursively(item_child) else: - # if item_child['name'] == self.item_name: - # if self.re_item_name.match(item_child['name']): if self.found_true_cond(item_child): item_child_copy = item_child.copy() item_child_copy.update({'color_formatter' : YELLOW, 'found' : 1}) @@ -77,6 +73,7 @@ class NerdTreeFind(NerdTree): def find_tree_struct(self): ''' + recreates the tree with search results ''' results = self.find_node() @@ -85,11 +82,6 @@ class NerdTreeFind(NerdTree): if not results: return {} - # if dont_show_children_nodes: - # for result in results: - # children = result.get('children') or [] - # result['nchildren'] = len(children) - # result['children'] = [] dont_show_children_nodes = self.find_opts['dont_show_children_nodes'] if self.find_opts.get('dont_show_children_nodes') is not None else False self.opts['dont_show_children_nodes'] = dont_show_children_nodes