show symbolic link
This commit is contained in:
		
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							| @@ -8,7 +8,7 @@ You can search in a particular subtree for files or folders that match a regular | ||||
|  | ||||
| In my opinion the better solution is:<br /> | ||||
| 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 | ||||
| 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 | ||||
| @@ -23,7 +23,13 @@ vfind ~/nerd_tree/ "(.*)rem(.*)" | ||||
| ``` | ||||
|  | ||||
| all items matching the pattern are show in the result tree.<br /> | ||||
| The folder matching the pattern are show with information about the total number of files and the size of the subtree. | ||||
| You can use as pattern any valid regular expression, for example pattern as this | ||||
|  | ||||
| ``` | ||||
| vfind ~/nerd_tree/ "(.*)rem|tree(.*)" | ||||
| ``` | ||||
|  | ||||
| The folder matching the pattern are show collapsed 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** | ||||
|  | ||||
| ``` | ||||
|   | ||||
							
								
								
									
										17
									
								
								src/tree.py
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								src/tree.py
									
									
									
									
									
								
							| @@ -26,10 +26,10 @@ class NerdTree(): | ||||
|  | ||||
|     if path_object.is_dir(): | ||||
|       item_type = 'd' | ||||
|     elif path_object.is_file(): | ||||
|       item_type = 'f' | ||||
|     elif path_object.is_symlink(): | ||||
|       item_type = 'l' | ||||
|     elif path_object.is_file(): | ||||
|       item_type = 'f' | ||||
|  | ||||
|     assert item_type | ||||
|  | ||||
| @@ -81,12 +81,15 @@ class NerdTree(): | ||||
|     start_dir_item_type, start_dir_object = self.get_path_obj(startpath) | ||||
|     stat_dir_item = start_dir_object.lstat() | ||||
|  | ||||
|     start_dir_target = start_dir_object.resolve() if start_dir_object.is_symlink() else '' | ||||
|  | ||||
|     if path: | ||||
|       path.append({ | ||||
|         'name' : rootnode, | ||||
|         'type' : start_dir_item_type, | ||||
|         'abs_path' : startpath, | ||||
|         'size' : stat_dir_item.st_size, | ||||
|         'target' : str(start_dir_target), | ||||
|         }) | ||||
|     else:  | ||||
|       path = [{ | ||||
| @@ -94,6 +97,7 @@ class NerdTree(): | ||||
|         'type' : start_dir_item_type, | ||||
|         'abs_path' : startpath, | ||||
|         'size' : stat_dir_item.st_size, | ||||
|         'target' : str(start_dir_target), | ||||
|         }] | ||||
|  | ||||
|     d = { | ||||
| @@ -103,6 +107,7 @@ class NerdTree(): | ||||
|       'children' : [], | ||||
|       'path': path, | ||||
|       'size' : stat_dir_item.st_size, | ||||
|       'target' : str(start_dir_target), | ||||
|       } | ||||
|  | ||||
|     # using listdir | ||||
| @@ -114,7 +119,7 @@ class NerdTree(): | ||||
|       d.setdefault('not_readable', 1) | ||||
|  | ||||
|     for item in items: | ||||
|       if item in self.opts.get('items_to_exclude') or []: | ||||
|       if item in (self.opts.get('items_to_exclude') or []): | ||||
|         continue | ||||
|  | ||||
|       abs_path_item = startpath+item | ||||
| @@ -125,11 +130,14 @@ class NerdTree(): | ||||
|       if path_object.is_dir(): | ||||
|         d['children'].append(self.tree_struct(abs_path_item, path=path[:])) | ||||
|       else: | ||||
|         target = path_object.resolve() if path_object.is_symlink() else '' | ||||
|  | ||||
|         path_copy = path[:] | ||||
|         path_copy.append({ | ||||
|           'name' : item, | ||||
|           'type' : item_type, | ||||
|           'abs_path' : abs_path_item | ||||
|           'abs_path' : abs_path_item, | ||||
|           'target' : str(target), | ||||
|           }) | ||||
|  | ||||
|         d['children'].append({ | ||||
| @@ -138,6 +146,7 @@ class NerdTree(): | ||||
|           'abs_path' : abs_path_item, | ||||
|           'path' : path_copy, | ||||
|           'size' : stat_item.st_size, | ||||
|           'target' : str(target), | ||||
|           }) | ||||
|  | ||||
|     return d | ||||
|   | ||||
| @@ -43,6 +43,9 @@ def produce_treeline(prec_seps, lsep): | ||||
|         item_name = item['name'] | ||||
|       tomount = sep + item_name | ||||
|  | ||||
|       if item['type'] == 'l' and item['target']: | ||||
|         tomount += ' -> %s' % ((item['target'],)) | ||||
|  | ||||
|       # if item.get('type') == 'd': | ||||
|       #   if item.get('nchildren') is not None: | ||||
|       #     tomount += '(%s)' % (item['nchildren'],) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user