Open romkatv opened 5 years ago
Aww, man, I fixed that ages ago with expanding on this (my favourite) dir shorten strategy... #979
Currently requires POWERLEVEL9K_SHORTEN_DIR_LENGTH
to be set to something...
It's the best shortening strategy. Thanks for fixing it!
By the way, I've made a small change to it in Powerlevel10k. When it shortens a directory, it adds POWERLEVEL9K_SHORTEN_DELIMITER
like all other strategies. However, it uses *
as the default value of this parameter.
If you don't set POWERLEVEL9K_SHORTEN_DELIMITER
, you get this (using the example directory from https://github.com/bhilburn/powerlevel9k/pull/979):
~/g*/pr*/co*/s*/powerlevel9k
I like that I can see which directories got shortened, and it only costs one character. You can still copy-paste and tab-complete this path, which is the reason I've made *
the default delimiter for this strategy.
You can get the original behavior with POWERLEVEL9K_SHORTEN_DELIMITER=""
:
~/g/pr/co/s/powerlevel9k
Or if you don't care about tab-completion but do like the actual shortening algorithm, you could go with POWERLEVEL9K_SHORTEN_DELIMITER=$'\u2026'
(dots) like in other strategies.
What do you think? Would this be useful for Powerlevel9k users?
I like that I can see which directories got shortened, and it only costs one character. You can still copy-paste and tab-complete this path, which is the reason I've made
*
the default delimiter for this strategy.
This is a great idea. I hope I get this PR merged someday 😅
A little bit off topic, but since you modified the behaviour. Have you changed how spaces and such are handled? There is probably a good way to handle it with (q)
but I never got it to work properly so I ignored it as a known issue
Example:
mkdir /tmp/bla{\ foo,bar}
cd /tmp/bla\ foo
To make this usable in copy paste fashion it would need to be /t/bla\
or /t*/bla\ *
In general, directory in the prompt is printed in unquoted form. Whether your prompt is %~
or %/
, you cannot expect to be able to copy-paste the directory from the prompt and ls
it or cd
into it. Things like spaces, brackets and dollar signs will have to be escaped. It's a trade-off between copy-pastability and readability. The common practice is clearly favoring readability.
Just like you usually but not always can copy-paste a directory from a regular prompt and cd
into it, you usually but not always can copy-paste the directory shortened with truncate_to_unique
and tab-complete it. It's possible to make tab-completion always work, just like it's possible to make cd
always work, but it'll make the path less readable and will run counter to the user expectations due to the prevailing practice of displaying unquoted directory in the prompt. So I think it's WAI.
By the way, I've made another change to truncate_to_unique
in Powerlevel10k. It respects POWERLEVEL9K_SHORTEN_FOLDER_MARKER
, which I also changed to default to (.bzr|CVS|.git|.hg|.svn|.citc)
-- a much more useful default compared to the almost useless ".shorten_folder_marker"
. In plain English it means that in Powerlevel10k truncate_to_unique
does not shorten the following directories:
max(1, POWERLEVEL9K_SHORTEN_DIR_LENGTH)
.oh-my-zsh
tree, you'll still see untruncated /oh-my-zsh/
in the path because there is .git
in it. This can be disabled by explicitly setting POWERLEVEL9K_SHORTEN_FOLDER_MARKER=""
.This is again a compromise between verbosity and information content. There aren't that many parent directories that are vcs repository roots and they are rather important for orienting oneself, so I find it valuable to always see them.
That is a nice idea! I had some thoughts about restructuring the dir segment a little bit...
how can I achieve something like:
~/.../parent/current
To reproduce:
Actual result: Directory in the prompt is not truncated.
Expected result: Directory in the prompt is truncated. It's unclear from the docs exactly how it should be truncated but truncated it should be.