Open tcbegley opened 5 years ago
good catch @tcbegley , thanks
What would be the most useful here? Something like notebooks/.../<last-directory>/<filename>
?
For me that would be perfect
I reckon what makes sense is to recursively remove directories before the last directory until it gets to an acceptable path length
An alternative which provides more context than eliding intermediate directory names is to keep only the first character of each parent directory's name. For example, /project/some/very/long/nested/path/foo.ipynb
would be displayed as /p/n/s/v/l/n/p/foo.ipynb
. This is especially useful if the project contains multiple directories with generic names used in multiple places. For example:
$ tree /project
/project
├── exploration
│ ├── doc
│ ├── notebooks
│ └── src
├── modelling
│ ├── doc
│ ├── notebooks
│ └── src
└── visualisation
├── doc
├── notebooks
└── src
I think just sticking a single letter in there is a bit confusing. I've just written something that replaces the longest directory with the first letter + … recursively, and if that doesn't get it below the char limit, it starts removing directories entirely (replacing with a single …)
Does this seem reasonable?
_trim_path('/hi/this/is/a/really_really/reeeeeeeeeeeeeeeeeally/loooooooooooooooooooooong/path.file')
'hi/this/is/a/really_really/r…/l…/path.file'
To me that's more confusing than always reducing to a single character. Additionally, it's less apparent why a particular directory name has been elided than if it was just applied left-to-right, for example.
Thanks for everyone's contributions and enthusiasm.
Scott's suggestion is fairly common (the Fish prompt does this by default, I think, or maybe it's just my prompt), and should therefore be fairly familiar. That said, I think Jan's idea of having a first letter + ...
is somewhat more legible, at the cost of an extra character. Ultimately I don't really care -- I think we should just try it.
In terms of where to truncate, I believe it'd be more aligned with people's expectations (and probably more useful) to start truncating directories at the beginning of the path rather than at the end, or rather than choosing the longest directories:
/hi/this/is/a/really_really/reeeeeeeeeeeeeeeeeally/loooooooooooooooooooooong/path.file
=>
/h/t/i/a/r/r/loooooooooooooooooooooong/path.file
/h…/t…/i…/a…/r…/loooooooooooooooooooooong/path.file
Can we just test that the ellipsis character prints reasonably on the Cygwin terminal in the Windows computer?
will do @pbugnion!
Can confirm that this does indeed print in cygwin.
When using watch mode on a large project with many nested directories, I see only the first part of the path before it gets truncated. In particular the actual file name is hidden. Resizing the window has no effect.
Would it be possible to display something like
notebooks/.../folder/notebook_name.ipynb
etc.?