Closed tru2dagame closed 3 years ago
Please attach your ~/.p10k.zsh
.
@romkatv Thanks for the reply. Here is my .zshrc
and .p10k.zsh
~/.zshrc
~/.p10k.zsh
Basically what I want is to skip the exec zsh
step.
The DIR element would automatically goes to newline so that I can still show some info of the right prompt elements.
function p10k-on-pre-prompt() {
emulate -L zsh -o extended_glob
if [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) ]] || [[ $(pwd | wc -m) > 50 ]]; then
p10k display '1/left/my_fire_dir'=hide '2'=show
else
p10k display '1/left/my_fire_dir'=show '2'=hide
fi
}
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
os_icon context my_fire_dir vcs newline
my_fire_dir newline
prompt_char
)
This snippets above should work if I am in git repo or if the current dir characters are greater than 50.
This diff against .p10k.zsh
that you've posted earlier should do it. It's much faster than the solution you've posted in the last comment.
@@ -35,6 +35,7 @@
os_icon # os identifier
dir # current directory
vcs # git status
+ newline dir
# =========================[ Line #2 ]=========================
newline # \n
prompt_char # prompt symbol
@@ -1560,6 +1561,16 @@
prompt_example
}
+ function p10k-on-pre-prompt() {
+ emulate -L zsh -o extended_glob
+ local dir=${(%):-%~}
+ if (( $#dir > 50 )) || [[ -n ./(../)#(.git)(#qN) ]]; then
+ p10k display '1/left/dir'=hide '2'=show
+ else
+ p10k display '1/left/dir'=show '2'=hide
+ fi
+ }
+
# User-defined prompt segments can be customized the same way as built-in segments.
# typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208
# typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐'
@romkatv thanks for this amazing guide!
Now I'm calculating the left space to make it even better.
if (( COLUMNS - $#dir < 50 )) || [[ -n ./(../)#(.git)(#qN) ]]; then
Hi,
I'd like to keep the full dir for some reason.
Is it possible to change the
LEFT_PROMPT_ELEMENTS
to add a newline fordir
when my current pwd is too long (or depends on space left percentage)?Currently I need to reload the zsh to change the newline.
Thanks.