Closed henderea closed 2 years ago
This is one of the bugs in p9k that has been fixed in p10k. There is no option to turn the bug back on.
That's rather unfortunate. I use the aliases as typing shorthands, but I do not like using them for display. If this isn't going to be re-added, then I guess I'll just stick with 9k, since it works the way I like.
I don't intend to revert to the old behavior.
By the way, I consider the behavior in p9k a bug because it diverges from standard prompt expansion in zsh. There is %/
for absolute and %~
for "shortened". There is no escape sequences for something that shortens $HOME
but doesn't shorten named directories.
Well, I suppose that's fair.
Honestly, the reason it's an issue for me is because I'm trying to use the functionality to give me shorthands for typing that the shell will expand to the full path, but I don't really want to "name" the directory. My shorthands aren't exactly human-readable, so it looks pretty horrible in a prompt.
If there's an alternate ZSH functionality that supports expansion-only shorthands (similar to what alias
does for commands), that would probably be the better way for me to do my setup.
Is there any chance you might make a way to hook into the prompt_dir
code to fully customize directory display? If I could manually override the behavior with custom code, I could probably get what I want.
I don't think I understand the problem. If you type rm ~doc/foo
, you'll see rm ~doc/foo
in the scrollback and in history. And if you type cd ~doc
, you'll see ~doc
as your current directory. It's all consistent. When you type cd ~doc
, you supposedly know that ~doc
is the directory you want -- otherwise you wouldn't be able to type it. So seeing it in prompt shouldn't confuse you.
This works exactly like aliases. If you define alias ll='ls -lA'
and then type ll
. You'll see ll
in the scrollback and in history. You won't see the expansion.
Let's drop this discussion. It's not really my intention to convince you to change your habits. If p9k works fine for you, it's fine to keep using it.
Is there any chance you might make a way to hook into the
prompt_dir
code to fully customize directory display?
I have many items on my TODO list that I consider more important, and there is virtually zero chance I'll ever get to the bottom of my TODO list.
After the discussion, I realized I could just do a custom segment instead of customizing the built-in dir
segment, so I've managed to create what I want with this my_dir
segment:
prompt_my_dir() {
local p=${PWD/#(#b)$HOME(|\/*)/'~'$match[1]}
local -a parts=("${(s:/:)p}")
if [[ $p == ('~'|'~/'*) ]]; then
parts[1]=$POWERLEVEL9K_HOME_FOLDER_ABBREVIATION
elif [[ $p == '/' ]]; then
parts=($POWERLEVEL9K_FOLDER_ABBREVIATION)
else
parts[1]=$POWERLEVEL9K_FOLDER_ABBREVIATION
fi
local sep=$POWERLEVEL9K_DIR_PATH_SEPARATOR
local content="${(pj.$sep.)parts}"
p10k segment -t $content -b blue
}
Sorry for the trouble.
Looks good to me 👍
When I upgraded from 9k, the directory component started using the alias (
hash -d
) instead of the full path from home/root. I would like to get the old behavior of ignoring the directory aliases when showing the path.Basically, if I have
hash -d doc=$HOME/Documents
, I used to see the path show the home icon and thenDocuments
. In the 10k theme, it instead just shows~doc
, which I am not a fan of. I was hoping to keep my prompt identical to 9k, but this is preventing that from happening.How do I disable the display of directory aliases in the 10k theme? I really don't like the shortening, so I'm currently forced to stick with the 9k theme to avoid it.
To be clear, I want to do this without altering anything other than the theme settings. It looks like the case for handling the
auto_name_dirs
option in the code might be what I want, but I'm pretty sure setting that option would change stuff beyond the theme. I really only use the aliases to shorten the amount I have to type; I don't want to use them for display.