tree - Troubleshooting
- Problem:
When copying the result of a
treecommand into a text editor, it may happen that artifacts appear instead of space character. For instance, in Pycharm, copying this output from the Terminal. └── mychart ├── Chart.yaml ├── charts │ └── mysubchart │ ├── Chart.yaml │ ├── charts │ ├── templates │ │ └── configmap.yaml │ └── values.yaml ├── templates │ ├── _helpers.tpl │ └── configmap.yaml └── values.yamlinto Pycharm, it looks like this
.└── mychart├── Chart.yaml├── charts│NBSP NBSP └── mysubchart│NBSP NBSP ├── Chart.yaml│NBSP NBSP ├── charts│NBSP NBSP ├── templates│NBSP NBSP │NBSP NBSP └── configmap.yaml│NBSP NBSP └── values.yaml├── templates│NBSP NBSP ├── _helpers.tpl│NBSP NBSP └── configmap.yaml└── values.yaml- Cause:
The artifact is a non-breaking space character, a specialized version of a regular space, which prevents line breaks. Apparently,
treehas been using it since very early on and the problem only now arises due to some editors printing them. In Unicode they are defined asU+00a0, whereas the regular space is defined asU+0020. In the editor, there is no mechanism to replace those characters and most fonts have display character associated to it, which leads the the obscure output (NSBP actually stands for, non-breaking space).- Solution:
Search for
[\u00A0]characters in the document (regex search must be active) and replace each match with a single space character.