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

Adds a max_length property to the style "Agnoster Short" of "Path" segments #5016

Open
1 task done
Diogo-Rossi opened this issue Jun 6, 2024 · 2 comments
Open
1 task done
Assignees
Labels
🚀 feat New feature

Comments

@Diogo-Rossi
Copy link

Diogo-Rossi commented Jun 6, 2024

Code of Conduct

  • I agree to follow this project's Code of Conduct

What would you like to see changed/added?

In Path segment, the "Agnoster Short" style has a max_depth property:

Agnoster Short
When more than max_depth levels deep, it renders one folder_icon [...] followed by the names of the last max_depth folders, separated by the folder_separator_icon.

I would like to have a different property named max_length.
So, when the full current working directory string has more than max_length characters, it renders the names of the last folders until it reaches max_length characters.

Example:

Suppose that max_length=36 and the current work directory is C:/Users/myUser/folder
Then, the length of the current work directory is: 22 if you count the separators, 19 if you don't count separators.
In any case, it is less than 36, so it would display the full current working directory as a full string.

Now, suppose that max_length=36 and the current work directory is C:/Users/myUser/folder/subfolder/last_folder
Then, the length of the current work directory is: 44 if you count the separators, 39 if you don't count separators.
In any case, it is greater than 36, so it would display the names of the last folders until the full string reaches <= 36 characters, i.e.:

C:/📁/📁/folder/subfolder/last_folder

(This has 35 characters if you count the separators, 30 if you don't count them)

  • TBD: You could count separators or not.
  • TBD: You could count the root folder or not (using hide_root_location maybe?)

Is that feasible?

@JanDeDobbeleer
Copy link
Owner

@Diogo-Rossi this implies a completely new style as we do not loop the folder backwards just yet. But this can be done. I would count the separators as that's more intuitive when deciding prompt length. I would always count the root too for the same reason.

@lewis-yeung
Copy link
Contributor

@JanDeDobbeleer Agreed. The separators should be counted, so we can implement it just like the max_width property for the powerlevel style, and the underlying logic can be reused, IMO. But before this I have to finish a fix for several bugs in a path segment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 feat New feature
Projects
None yet
Development

No branches or pull requests

3 participants