JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
15.88k stars 2.28k forks source link

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

Open Diogo-Rossi opened 1 month ago

Diogo-Rossi commented 1 month ago

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)

Is that feasible?

JanDeDobbeleer commented 3 weeks ago

@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.