I might overlook a configuration option, but would it be possible to add some switch such that the path is only shortened until it reaches a (configurable) portion of $COLUMNS?
=> In small terminals the shortened path would be visible allowing for enough space for the actual command, in large terminals the full path is visible.
Hi @jadoro !
Sorry for the late answer. :/
Just to understand you correctly: You want to set a max width of the dir segment, right? And set that in percent of the total width of the terminal window, right? For example, if my terminal emulator shows 100 columns, and you set the max size of the dir segment to 10 percent, the path would be truncated (from left) if it is longer than 10 characters?
That sounds doable. Nice Idea! 馃憤
Exactly!
I tend to have different terminal sizes (notebook vs desktop, fullscreen vs half, you name it) and always getting the most information about the current working directory without lacking space for the actual command would be awsome.
Thanks for your great work!
I'd also like to see this added, but I have another related feature idea if we're thinking of fixing up the dir prompt,

I have my dir set to "fish-style" but it's not giving me enough information to determine my full path, as it becomes ambiguous. For example, https://asciinema.org/a/0gW6B2QrHTTzgZAGM7se6xYa8 shows how the directory path would be become ambiguous.

Here in a real fish shell, directories with a . at the front don't get chopped so far that we don't have any idea where we are in the surplus of home directory dotfiles.
Having an option to shrink only as much is needed (and another to prevent ambiguous situations at all?) would be a great feature.
This seems like a great enhancement. Thanks for the input, @jadoro!
@robobenklein - I think I'm having trouble understanding your example, actually. I watched the termcap and am looking at the images you posted, but I'm having trouble understanding how it disambiguates the full path. It looks to me, in that image, like hidden directories do in fact get truncated?
Here's a better example sorry,
Both in the same directory:

Since there are so many ~/. folders, it adds the .c instead of . so when typing .c/n/c then tab complete, it expands to .config/nvim/colors whereas typing ./n/c doesn't expand properly.
@robobenklein Just to get you right, fish truncates the path to the minimal amount of characters that are non-ambiguous, right? It has been a while since I used fish, but the behaviour was not limited to hidden folders, was it?
But to answer the feature request:
It would be a hard thing to do from the perspective of P9K, as we would have to check every sibling-folders for every parent folder and find the shortest non-ambiguous name. That would be probably quite slow.
Sounds like quite a bit of work. Not impossible, though.
Thanks, @robobenklein! That example was great.
Agreed with @dritter's comments. We would need to fire off a subprocess that globbed each directory, which would be expensive. Realistically, I don't know that this is feasible within P9k.
That said, it may be worthwhile to always show two characters if the first one is a . in the dirname, as a . may be confused for the currentdir. Thoughts, @dritter?
That said, it may be worthwhile to always show two characters if the first one is a . in the dirname, as a . may be confused for the currentdir.
That might be helpful.
And about the general idea: The performance might be less a problem, once we switch to async..
echo ${${:-/${(j:/:)${(M)${(s:/:)${(D)PWD:h}}#(|.)[^.]}}/${PWD:t}}//\/~/\~}
I think this was stolen from @mcornella
Shows the dot for hidden dirs + the first letter. We could use something similar here.
Also, just found a reference on the zsh mla: https://www.zsh.org/mla/workers/2009/msg00415.html
I'm working on updating it with a few other things like ~ and auto abbreviation, I'll post back here when I have something decent.
Update: I have a working method which I'm using to get this functionality.
First, rtab is my slightly modified rtab script at https://github.com/robobenklein/configs/blob/master/bin/rtab
Then it's just a custom segment that I use instead of dir:
POWERLEVEL9K_CUSTOM_RTAB_DIR="echo \$(rtab -t -l)"
I'm going to close this one out due to staleness. This should be easier with an async engine, which the new code makes possible, but it doesn't look like anyone is taking on this enhancement.
Most helpful comment
I'd also like to see this added, but I have another related feature idea if we're thinking of fixing up the dir prompt,
I have my dir set to "fish-style" but it's not giving me enough information to determine my full path, as it becomes ambiguous. For example, https://asciinema.org/a/0gW6B2QrHTTzgZAGM7se6xYa8 shows how the directory path would be become ambiguous.
Here in a real fish shell, directories with a
.at the front don't get chopped so far that we don't have any idea where we are in the surplus of home directory dotfiles.Having an option to shrink only as much is needed (and another to prevent ambiguous situations at all?) would be a great feature.