-
Notifications
You must be signed in to change notification settings - Fork 947
Add "truncate_with_folder_marker" shorten strategy #398
Conversation
powerlevel9k.zsh-theme
Outdated
|
||
zero='%([BSUbfksu]|([FB]|){*})' | ||
current_path=$current_path${PWD:${#${(S%%)last_marked_folder//$~zero/}}} | ||
;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't really know what I was doing with this function. The "loop" technique works but I'm not sure what effet it has on performance. Maybe someone with a stronger knowledge of bash or zsh can optimize it later...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dritter @BenoitAverty - What are your thoughts on Benoit's comment, here? Do you want to iterate on this function or should we merge as-is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bhilburn Thanks for pointing me to this again. This is a quite complicated pattern to count the visible characters in the prompt. In our case we count the characters in $last_marked_folder
(which should not contain any non-visible characters) and replace the amount of characters in $PWD
from the left with nothing. IMHO this could be done way easier (just replace the characters from the left), but I think @BenoitAverty just took this pattern from the truncate_with_package_name
strategy. As far as I can see this pattern originates from barts prompt. For more information about this pattern, see this answer on StackOverflow.
Regarding the performance of upsearch
function. For me it looks quite solid. Nothing to optimize here.
This is really well done, @dritter. I especially like your approach to creating user documentation, which I think makes things easier to use. @BenoitAverty - This is a great idea, and I appreciate you providing input & review on this PR. Thanks for coming up with so many great improvements for the project! |
Now the current folder in `truncate_with_folder_marker` strategy is truncated by cutting off the found folder from the beginning of $PWD.
I just got rid of the ugly pattern. Now the current path is truncated by removing the matched path from @BenoitAverty could you confirm that everything still works as expected? I mean, I have tested it as well, the tests are green, but the more eyes, the better. 😉 Thanks in advance. |
Btw. There is still this ugly pattern in |
I did a quick test just now, it seems to work OK. I may have forgotten some edge cases, but it works with one and two markers in the hierarchy so it should work in all cases. |
Good to hear! Thanks for testing @BenoitAverty |
Awesome :) |
This adds @BenoitAverty
truncate_with_folder_marker
strategy for thedir
segment.