-
-
Notifications
You must be signed in to change notification settings - Fork 531
Description
As the CWD column is usually shorter than the paths it needs to display it would be nice to shorten the displayed path such that more relevant parts are kept visible.
Full: /var/lib/postgresql/12/main
Current: /var/lib/postgresql/12/ma
Proposed: /var/lib/postgre~/12/main
The general algorithm could be something linke this:
-
If string fits into target width, keep as is. Terminate this algorithm as soon as the resulting string fits.
-
Shorten from back of last, non-terminal path component until only one unshortened character remains (skip two-char components):
/var/lib/postgres~/12/main /var/lib/postgre~/12/main /var/lib/postgr~/12/main /var/lib/postg~/12/main /var/lib/post~/12/main /var/lib/pos~/12/main /var/lib/po~/12/main /var/lib/p~/12/main -
Repeat process with all path components before this.
/var/lib64/p~/12/main /var/lib~/p~/12/main /var/li~/p~/12/main /var/l~/p~/12/main /v~/l~/p~/12/main -
combine multiple (shortened) path components
/v~/l~/p~~/main /v~/l~~/main /v~~/main -
Shorten the last label from the middle, prioritizing to keep the front (keeping at least first+last char)
/v~~/m~n
If the length that can be gained from shortening the last label exceeds what can be gained from step 3 than step 4 is prioritized.
The overall concept can likely also be reused for the CGROUP column (cf. #217).