nerd_tree/README.md

93 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

2024-02-05 14:03:44 +01:00
# Visual Find
**vfind** is a tool written in python based on *nerd_tree*.<br />
Its purpose (and base idea) is to blend the unix command *find* with the *tree* command.<br />
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).<br />
## Installation on your system
In my opinion the better solution is:<br />
1. Clone the repository in your home folder
2024-02-05 17:05:39 +01:00
2. Go to your home folder and make a symbolic link to the command in your ~/bin folder
2024-02-05 14:03:44 +01:00
```
cd ~/nerd_tree
ln -s ~/nerd_tree/vfind.py ~/bin/vfind
```
## How to use
2024-04-08 10:20:44 +02:00
**vfind** has 2 mandatory arguments, the *path* of subtree from which to begin the search and the *search* pattern.
The **search** pattern can be:
- an expression whith wild card supporting the shell expansion, the default
- a regular expression, using the flag -re
2024-02-05 14:03:44 +01:00
```
2024-04-11 13:17:13 +02:00
vfind ~/nerd_tree/ -re '(.*)rem(.*)'
2024-02-05 14:03:44 +01:00
```
2024-02-23 11:35:46 +01:00
all items matching the pattern are show in the result tree: in this specific case any name containing **rem** substring<br />
2024-04-08 10:20:44 +02:00
The same results above can be achieved using the command version with the shell expansion:
```
2024-04-11 13:17:13 +02:00
vfind ~/nerd_tree/ '*rem*'
2024-04-08 10:20:44 +02:00
```
2024-05-10 16:39:13 +02:00
![vfind ~/nerd_tree/ '*rem*'](/screenshot/vfind_1.jpg)
2024-04-08 10:20:44 +02:00
2024-02-05 17:05:39 +01:00
You can use as pattern any valid regular expression, for example pattern as this
```
2024-04-11 13:17:13 +02:00
vfind ~/nerd_tree/ -re '(.*)rem|tree(.*)'
2024-02-05 17:05:39 +01:00
```
The folder matching the pattern are show collapsed with information about the total number of files and the size of the subtree.
2024-02-05 14:03:44 +01:00
If you want to show the subtree expanded you can use the flag **-s**
```
2024-04-11 13:17:13 +02:00
vfind ~/nerd_tree/ -re '(.*)rem(.*)' -s
2024-02-05 14:03:44 +01:00
```
2024-05-10 16:42:41 +02:00
![vfind ~/nerd_tree/ -re '(.*)rem(.*)' -s](/screenshot/vfind_2.jpg)
2024-02-23 11:35:46 +01:00
## Include/Exclude path
2024-01-15 09:04:53 +01:00
2024-02-23 11:35:46 +01:00
You can include a set of results selecting specific branch (or paths) with the option **-i** (include).
2024-04-11 13:17:13 +02:00
In this case the match is made exactly on the pattern provided, for example:
2024-02-23 11:35:46 +01:00
```
2024-04-11 13:17:13 +02:00
vfind ~/nerd_tree/ -re '(.*)py' -i src
2024-02-23 11:35:46 +01:00
```
include the results that along the path have the name **src**.<br />
2024-04-08 10:20:44 +02:00
**NOTE** the command above is equivalent to
```
2024-04-11 13:17:13 +02:00
vfind ~/nerd_tree/ '*py' -i src
2024-04-08 10:20:44 +02:00
```
2024-04-11 13:17:13 +02:00
You can include the -i more than once as in this case:
2024-03-14 14:46:57 +01:00
```
2024-04-11 13:17:13 +02:00
vfind ~/nerd_tree/ -re '([0-9][0-9])|(^tree_(.*))' -i src -i .git
2024-03-14 14:46:57 +01:00
```
2024-04-08 10:20:44 +02:00
the above command will search for files or folders with a **two digits** name or with the name beginning with **tree_**
2024-03-14 14:46:57 +01:00
only in the path ***src*** or ***.git***
2024-04-11 13:17:13 +02:00
In a similar manner you can exclude from the results tree paths or items with the option **-e**.
> The **-e** option can be any valid pattern that support the shell expansion
too in this case you can specify more than once the option -e
```
vfind ~/nerd_tree/ -re '(.*)py' -e src
```
2024-02-23 11:37:14 +01:00
```
2024-04-11 13:17:13 +02:00
vfind -e .git -e __pycache__ ~/nerd_tree/ 'ntree*'
2024-02-23 11:37:14 +01:00
```
2024-05-10 16:42:41 +02:00
![vfind -e .git -e __pycache__ ~/nerd_tree/ 'ntree*'](/screenshot/vfind_3.jpg)