Closed romkatv closed 1 year ago
+1 This would be amazing. I would love to help too. (in whatever way I can)
Hi @romkatv Thanks so much for submitting this and your offer to help make Powerlevel10K work with Warp! We have notified the engineers that worked on this, they are gathering the details and will respond on this thread.
Please add a :+1: to the original post at the top to signal that you want this feature, and hit the subscribe button if you'd like to be notified.
Thanks @romkatv for helping, i'd love to have powerlevel10k working with warp asap!! 💪
Any news from this? 🤔
Closing as there doesn't seem to be any interest from the devs.
@romkatv Hey! We're definitely interested, and would love to work with you to get p10k working well within Warp. I'm so sorry that we haven't been more proactive about reaching out; we were trying to collect institutional knowledge about the issues we uncovered when investigating the p10k compatibility problem a long time ago, and then the person who was going to reach out went OOO.
Give me a couple days to build an up-to-date understanding of the specific issues that appear when trying to use Warp with p10k and I'll reply with them here.
In the meantime, can you link me to the part of the p10k codebase that adds the annotations you were mentioning? I can mentally map that onto what would make sense for Warp and be better able to make a suggestion about a path forward.
Again, really sorry that we dropped the ball here.
No worries, I understand that things can be hectic in a fast-moving project.
If you search for "_POWERLEVEL9K_TERM_SHELL_INTEGRATION" within p10k.zsh, you'll find most of the shell integration code. This code is nearly impenetrable, which is why I offered to make changes to it myself.
Powerlevel10k has a few capabilities that might prove challenging to handle. Let me summarize them.
Here's an example where a multi-line prompt changes to a single-character prompt on ENTER.
Here prompt is contracted on ENTER but it can also expand. For example, some users like to have timestamps on past prompt commands without having the timestamp on the current prompt. In this case a timestamp is added to prompt when you press ENTER.
Here's an example where prompt shows Google Cloud credentials and Kubernetes context when the command you are typing invokes gcloud
or kubectl
respectively.
Some prompt segments can update asynchronously. In practice this means that prompt may change on its own without any user action. This can lead both to contraction and expansion. In the extreme, even the height of prompt may change.
You most likely can already handle this because it's not unusual for zsh prompt to change on resize but I want to mention it for completeness. Here's an example (see the end of the recording):
This feature is meant to hide zsh initialization latency: instead of looking at an empty screen for some time after starting zsh, the user is instantly presented with a prompt and can start typing. When zsh is fully initialized, the fake prompt is replaced with the real thing.
In this example the real prompt looks the same as the fake prompt but it can also be different. For example, if the current directory is under a git repository, the fake prompt won't have git status but the real prompt will.
More info about this feature: https://github.com/romkatv/zsh-bench#instant-prompt
Hey @romkatv, one question for you while I work out a more complete technical design on our end:
I see that the escape sequence OSC 133 ; A ST
is sent before the prompt contents, and OSC 133 ; B ST
is sent after them. As far as I can tell, the right-side prompt is not included in this, and has no markers surrounding it. Would it be possible to introduce another pair of markers for the right-side prompt? I'm still doing some testing/prototyping on our end, but that might be the primary change needed on your end for things to work well.
I can embed any escape sequence in any place within powerlevel10k prompt you like.
Fantastic. In my prototype (where I modified _p9k_prompt_prefix_right
and _p9k_prompt_suffix_right
to add markers), I'm noticing some odd artifacts in the right-side prompt:
Any immediate thoughts as to what might be going on?
Here's the small adjustment I made:
if (( _POWERLEVEL9K_TERM_SHELL_INTEGRATION )); then
_p9k_prompt_prefix_left+=$'%{\e]133;A\a%}'
_p9k_prompt_suffix_left+=$'%{\e]133;B\a%}'
+ _p9k_prompt_prefix_right+=$'%{\e]133;C\a%}'
+ _p9k_prompt_suffix_right+=$'%{\e]133;D\a%}'
If you tell me how you want prompt to be marked, I'll make the changes.
Sure; I can keep working on the necessary changes for broad functionality on our end and assume that the changes you make will address any small oddities I encounter.
I'll leave a more detailed comment either tomorrow or Monday with the set of changes that we'll need on the p10k end to address compatibility issues!
It's really awesome to see how this thread made a 180° turn and see your collaboration and communication. Thank you for working on this to you both
Fantastic. In my prototype (where I modified
_p9k_prompt_prefix_right
and_p9k_prompt_suffix_right
to add markers), I'm noticing some odd artifacts in the right-side prompt:Any immediate thoughts as to what might be going on?
Here's the small adjustment I made:
if (( _POWERLEVEL9K_TERM_SHELL_INTEGRATION )); then _p9k_prompt_prefix_left+=$'%{\e]133;A\a%}' _p9k_prompt_suffix_left+=$'%{\e]133;B\a%}' + _p9k_prompt_prefix_right+=$'%{\e]133;C\a%}' + _p9k_prompt_suffix_right+=$'%{\e]133;D\a%}'
I believe this might be unrelated to P10k but rather Warp's line height implementation which does not seem centered. Not for the NerdFont Icons at least.
Using Starship, and the same Nerd Font icons I can achieve a P10k'esk look but it suffers from the exact same artifacts. Depending on the line height, font size and font face (Fira Code NF in this example), I can exaggerate the artifacts, or more specifically, NF icon alignment. The round shapes in your screenshot are NF Icons btw.
The most interesting part which I'd like to highlight, is that the alignment is different from box to box. Regardless of box content.
Hope this helps.
@pXius I believe "odd artifacts in the right-side prompt" was referring to "%b".
P.S.
The only way other terminals manage to render powerline glyphs (and sometimes UNICODE block characters) perfectly is by special-casing them in the rendered. You can notice that a terminal does this if it can display things like U+E0B0 even if there is no glyph for it in the font.
@pXius Yeah, the glyph alignment issues are largely a problem with the font, though there are also appear to be some small floating-point rounding(?) issues on our end, as you observed with the inconsistent vertical alignment from block to block. We'll eventually use the same trick as other terminals to get perfect rendering of these characters, but it's not super high on our priority list at the moment.
I figured out the %b bit; finishing up some prototyping/analysis and will return later today with details of what (I expect small) changes will be needed for proper Warp support!
Hey @romkatv - trying to debug one last possible integration issue: it seems like the updated prompts produced in response to changes in the input buffer (the functionality described here) don't currently include the start and end prompt markers that are sent for iTerm's shell integration; is that accurate? Want to make sure that the behavior I'm seeing is due to a lack of markers, and not some more significant logic error/compatibility issue on our end (we have a feature that I'm trying to make sure plays nicely with this p10k functionality).
powerlevel10k should write the markers every time it prints (or re-prints) prompt. There might be a bug that prevents this from happening but it's very unlikely.
Hey @romkatv - here's what we've come up with:
We'd like to prefix the right-side prompt with the sequence \e]133;P;k=r\a
, and use the same suffix as the left-side prompt (\e]133;B\a
). This follows the semantic prompts terminal-wg proposal here.
In terms of detecting when Warp is the active terminal, we set TERM_PROGRAM=WarpTerminal
in the shell environment, so you can reference that variable. Let me know if there's a different way you'd prefer to perform terminal detection.
For now, at least, we'll override POWERLEVEL9K_INSTANT_PROMPT=off
on our end to ensure there aren't any instant prompt-related issues. Once we've better tested this, we will remove the override in a future version where we're more confident there won't be any issues.
Finally, we'd like to be able to detect when a user has loaded an older version of p10k (one that doesn't contain the changes above) so we can prompt the user to update p10k for a better user experience. (We'll direct users to the update instructions on the p10k GitHub page.) Is there any way for us to perform a version check via shell variables, or should we just check the PS1
/PROMPT
/RPS1
/RPROMPT
variables for the marker sequences we're expecting?
If you'd like, you can send me a link to a branch with the relevant changes and I can test it out with my Warp-side changes to make sure everything works as expected before you merge it into your master branch.
Ack. This all sounds great to me. I'll go over your comment with greater attention and make necessary changes in p10k early next week. Will ping here.
I'm a user of Powerlevel10k coming from iTerm2 and wanting to be able to use it migrating to Warp. Thanks for working on it, I'm excited to use it.
I've opened https://github.com/romkatv/powerlevel10k/issues/2307 to track the development on Powerlevel10k side and made two changes within https://github.com/romkatv/powerlevel10k/tree/warp:
TERM_PROGRAM
is WarpTerminal
.TERM_PROGRAM
is WarpTerminal
.Please check whether the changes work for you. I don't have Warp installed, so I'm relying on your testing here.
You can use the following logic to detect Warp support within Powerlevel10k:
if (( ${+functions[p10k]} )); then
if [[ ${_p9k__param_pat-} == v<1-149>$'\1'* ]]; then
print 'Powerlevel10k predates Warp integration'
else
print 'Powerlevel10k has Warp integration'
fi
else
print 'Powerlevel10k not found'
fi
Note that _p9k__param_pat
is an internal parameter, which may disappear in the future. This is why the absence of _p9k__param_pat
signifies a new version of Powerlevel10k and thus with Warp support.
Generally looks good! I've got rendering working nicely (with some flicker prevention for transient prompts). I still need to add the logic to perform version checks, so not quite ready yet to LGTM your warp
branch, but will verify that last piece tomorrow.
Curious how this implementation will preserve "instant prompt"? Or will that be incompatible with Warp? So excited to see the support for this!
@romkatv Looks like the _p9k__param_pat
variable doesn't get initialized until the first precmd hook is executed? Ideally we'd be checking the p10k version after the user's rcfiles have been loaded but before the first prompt is rendered; is there any easy way to do that? Or should I shuffle things around on our end so that we check the variable in our own precmd hook instead (which runs after the ones installed from rcfiles)?
I've added P9K_VERSION
. This parameter is set when Powerlevel10k is sourced. You can use it like this:
if (( ! ${+functions[p10k]} )); then
print 'Powerlevel10k not found'
elif (( ! ${+P9K_VERSION} )); then
print 'Powerlevel10k predates Warp integration'
else
print 'Powerlevel10k has Warp integration'
fi
@romkatv I've got everything working nicely on our end with the latest p10k warp
branch! Feel free to merge it into p10k master
whenever you're ready; we'll be releasing the relevant changes on our end in two weeks (to make sure some associated riskier changes are stable before shipping them to users).
@jacksongoode At least initially, we'll disable the p10k instant prompt functionality, as Warp already provides something similar (you can start typing in the input before the shell is fully initialized) and the p10k instant prompt functionality causes issues. We may revisit this in the future, though!
I've merged powerlevel10k/warp into powerlevel10k/master.
Let me know if you want me to disable instant prompt in powerlevl10k when it detects Warp. I can also remove the instant prompt question from the configuration wizard when running under Warp.
We can disable instant prompt on our end (overriding the value of POWERLEVEL9K_INSTANT_PROMPT
to off
after sourcing user rcfiles). I think this is ultimately a better approach so that we can remove that line if/when we add support and it'll "magically" start working for users without any changes required on their end (including updating p10k to the latest version, unless we require p10k-side changes to make it work).
Thanks for the offer, though!
To Warp users watching this thread - current plan (barring any unforeseen issues that come up in our own internal testing) is that p10k support will go live next week. :)
Hey all, just following up on @vorporeal's update from last week-
We found a couple issues when dogfooding p10k support last week. Nothing serious, but things we'd like to address before launch. I'll be handling these final few fixes this week and we'll be aiming for launch next week (Thurs 6/15).
Thanks for your patience on this one -- really excited to finally get this out there!
Looking forward to finally can have both my favorite terminal components working seamlessly
You guys rock 🤘 @romkatv and the Warp team are rockstars
Hey all, I know many of you are super excited for p10k support to be available, so this is going to be frustrating. We weren’t able to land all of the fixes we needed in time for today’s release. We have merged them now and are actively dogfooding internally to make sure there aren’t any other bugs—we want to make sure that when it’s available, the experience is as great as you’ve come to expect from both Warp and p10k!
Getting this working for everyone is a top priority for me, so we’ll release it as soon as we’re confident it’s ready—ideally with the 6/22 release next week.
I use brew to install p10k, even after updating the latest version, warp still prompts
At the top of the .zshrc
file, it looks like this:
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
source /opt/homebrew/opt/powerlevel10k/powerlevel10k.zsh-theme
At the bottom of the .zshrc
file, it looks like this:
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
In other places in the file, there is no p10k-related configuration.
When I run the command exec zsh
, Warp can successfully identify and run p10k.
I noticed that the release version number of brew p10k is 1.18.0 :
romkatv/powerlevel10k/powerlevel10k 1.18.0
after using git pull the main branch. p10k one line mode works well but two lines mode has character zdislocation.
+1 ^^^
Using p10k through git pull directly in "/Users/[user]/.oh-my-zsh/custom/themes/powerlevel10k", also have the
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
block at the top of my .zshrc
but without the source ...
mentioned by @0xAWM. Somewhere near the bottom
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
All in all it looks like this right now. Haven't had a look into the grey arrows, why they do not have the correct color, but it is a start.
Thank you guys for making this work!
I've just released powerlevel10k v1.19.0 on homebrew.
Edit: I've also updated powerlevel10k submodule in prezto. To the best of my knowledge, all installation methods on macOS are now covered: if you update powerlevel10k, you'll be on v1.19.0.
When using the full two-line prompt with p10k, the right side does not render correctly:
Also, the powerline blocks are not well-aligned (UbuntuMono Nerd Font):
unfortunately it's kinda buggy, and the color shades are not usable as well, and we have to manually pic every shade one by one by hand which would be tedious. ( https://github.com/romkatv/powerlevel10k/issues/537)
and also the cursor doesn't honor the p10k possible positions.
for now unfortunately it's kinda not very usable.
Hey all, as you might have noticed, the latest Warp release includes p10k support! Special thanks to @romkatv for opening this issue and updating p10k to make this happen.
Note that p10k v1.19 (which includes those Warp-supporting changes) is required.
I'll look into the remaining visual inconsistencies with certain p10k configs -- thanks @ajeetdsouza @sepl2604 @0xAWM for pointing them out.
EDIT: You'll also have to enable "Honor user's custom prompt" in Settings > Features for the change to take effect! (When this setting is enabled, Warp renders your shell-specified prompt rather than Warp's native prompt):
thanks for the awesome job.
this is my current version of warp and powerlevel10k.
unfortunately despite being latest version of both, it has rendering issues, not just the shading ,but also rendering problems in the middle as well:
i have p10k installed through zinit but new terminals in warp don't use it. running zsh
will start a new subshell using p10k though – just new warp terminals won't use it. is there setting i'm supposed to configure to support this?
EDIT: CMD-P -> Honor PS1
fixes this!
@sepl2604 the color for those "arrow"-like chars is rendered grey due to Warp's minimum contrast setting (we update colors to enforce a minimum contrast ratio for readability)
You can disable this feature in the Settings pane, as shown below:
i have p10k installed through zinit but new terminals in warp don't use it. running
zsh
will start a new subshell using p10k though – just new warp terminals won't use it. is there setting i'm supposed to configure to support this?
I have the same problem. I need to type exec zsh
to p10k turn on. Can anyone help? Do we need to make some changes in .zshrc file?
@zachbai that did the trick, thanks for this tip!
i have p10k installed through zinit but new terminals in warp don't use it. running
zsh
will start a new subshell using p10k though – just new warp terminals won't use it. is there setting i'm supposed to configure to support this?I have the same problem. I need to type
exec zsh
to p10k turn on. Can anyone help? Do we need to make some changes in .zshrc file?
Anyone? 😊🙏
i have p10k installed through zinit but new terminals in warp don't use it. running
zsh
will start a new subshell using p10k though – just new warp terminals won't use it. is there setting i'm supposed to configure to support this?I have the same problem. I need to type
exec zsh
to p10k turn on. Can anyone help? Do we need to make some changes in .zshrc file?Anyone? 😊🙏
Tried to debug by putting echo "sourcing zshrc"
on top of ~/.zshrc
and it only appears after an exec zsh
and not on Warp startup.
Any advice on how to fix this issue is much appreciated.
not sure if this is going help everyone but i had the same problem. updated to latest p10k (1.19.0), did a bunch of stuffs including (CMD-P -> Honor PS1)but nothing worked unless i did exec zsh. warp wont start up with zsh + p10k.
So i ended up, uninstalling both p10k & omz and re-did everything (backedup my zshrc). seems to be working fine. simply upgrading p10k and having warp do the stuff seem to be buggy unless you clean up everything and do it fresh.
not sure if this is going help everyone but i had the same problem. updated to latest p10k (1.19.0), did a bunch of stuffs including (CMD-P -> Honor PS1)but nothing worked unless i did exec zsh. warp wont start up with zsh + p10k.
So i ended up, uninstalling both p10k & omz and re-did everything (backedup my zshrc). seems to be working fine. simply upgrading p10k and having warp do the stuff seem to be buggy unless you clean up everything and do it fresh.
I will try ;)
I'm the author and maintainer of powerlevel10k (a zsh theme). I see in the docs that Warp does not support powerlevel10k. Is there anything I can help you with?
I haven't used Warp but from other terminals with similar capabilities I gather that you need to annotate prompt and the command line with special escape codes. Powerlevel10k has built-in support for popular annotations. The right kind of annotation is enabled automatically based on the terminal (iTerm2, Kitty, VSCode, etc.). I could do the same for Warp but I would need to know what needs annotating. Perhaps you have a specification of the protocol?
Warp Internal (ignore) - linear-label:770f6576-d6c0-4e4f-a259-fc64b5156087