Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LP_PATH_METHOD truncate till VCS root #761

Open
sisoe24 opened this issue Dec 4, 2022 · 4 comments
Open

LP_PATH_METHOD truncate till VCS root #761

sisoe24 opened this issue Dec 4, 2022 · 4 comments
Labels
enhancement Feature request needs information More information needed from the reporter

Comments

@sisoe24
Copy link

sisoe24 commented Dec 4, 2022

Truncate path till VCS root directory.

Description

When changing the directory to a VCS directory, truncate everything before the VSC root directory.

How will this be useful?

When working in a VCS environment, most of the path that leads to it can be superfluous since the focus is the environment.

Example prompt

Screen Shot 2022-12-04 at 4

@sisoe24 sisoe24 added the enhancement Feature request label Dec 4, 2022
@Rycieos
Copy link
Collaborator

Rycieos commented Dec 5, 2022

Note that isn't a new suggestion: it was requested in #349 and then implemented in #465. However, since then, I have completely reworked how path generation is handled, and so #465 is very much impossible to merge.

I never got around to doing it myself as the original reporter and PR opener never reappeared. There didn't seem to be any interest in such a feature.

But now with this request, I will try to implement this myself. I admit that the new path shortening code is very complicated, so I wouldn't want to ask anyone else not familiar with it to attempt it.

@Rycieos Rycieos added this to the v2.2 milestone Dec 5, 2022
@Rycieos
Copy link
Collaborator

Rycieos commented Dec 5, 2022

Upon inspection and further thought; this needs some user stories.

If we add a new value for LP_PATH_METHOD, like truncate_to_vcs_dir, how would we know how to handle the rest of the shortening? For example, a directory like /Users/Rycieos/projects/liquidprompt/contrib/dist/archlinux-aur, where liquidprompt is the VCS root, and LP_PATH_LENGTH=35 and COLUMNS=100.

  1. Ignore the LP_PATH_LENGTH setting, and just do the VCS root shortening: liquidprompt/contrib/dist/archlinux-aur. (Note this is longer than the config specifies.)
  2. Make this VCS root truncating a different config option (like bool LP_PATH_VCS_ROOT_TRUNCATE), so that the different path shortening types could still be configured. Which would lead to displays like:
    a. LP_PATH_METHOD=truncate_chars_from_path_left: liquidprompt/.../dist/archlinux-aur
    b. LP_PATH_METHOD=truncate_chars_from_dir_right: liquidprompt/con.../dist/archlinux-aur
    b. LP_PATH_METHOD=truncate_chars_to_unique_dir: liquidprompt/c/dist/archlinux-aur
  3. Do the same as option 2, but instead of a new config option, we make LP_PATH_METHOD able to accept multiple types at the same time. So LP_PATH_METHOD='truncate_to_vcs_dir,truncate_chars_to_unique_dir' would result in: liquidprompt/c/dist/archlinux-aur. Then (where possible) we would do each shortening type in order, only continuing as long as the path continued to be too long.

Thoughts?

@Rycieos Rycieos added the needs information More information needed from the reporter label Dec 5, 2022
@nojhan
Copy link
Collaborator

nojhan commented Jan 8, 2023

I like the third idea, which may also have the potential to simplify the code. It should probably be added that the last method to be mentioned may be applied several times, whether the previous ones would be applied only once.

@Rycieos
Copy link
Collaborator

Rycieos commented Jan 8, 2023

It should probably be added that the last method to be mentioned may be applied several times, whether the previous ones would be applied only once.

I disagree, I think the first option should be applied as many times as possible, then the next one as many times as possible, etc. For options like what this issue is requesting, obviously you can only remove the part of the path before the VCS root once, so it doesn't matter.

@Rycieos Rycieos removed this from the v2.2 milestone Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request needs information More information needed from the reporter
Projects
None yet
Development

No branches or pull requests

3 participants