New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve preprompt on Ctrl+L #147
Conversation
Register a custom zle widget to clear screen using ansi codes instead of relying on builtin behavior.
@@ -153,6 +153,19 @@ antigen bundle sindresorhus/pure | |||
|
|||
## FAQ | |||
|
|||
### My preprompt is missing when I clear the screen with Ctrl+L | |||
|
|||
Pure doesn't register it's custom *clear-screen* widget if it has been previously modified. If you haven't registered your |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's => its
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! :)
Because some external zsh modules take control of your zsh widgets in an unobvious way, the user needs to know what is happening and how to fix it. I think it's better to let it break our custom clearing and let the user know why it boke. Trying to do the same as zsh-syntax-hilighting might result in odd cases where zsh-syntax-highlighting registers the builtin clear-screen widget and pure wrapping the custom highlighting widget resulting in multiple clear screens.
4961520
to
5cdac0e
Compare
Amended comments on readme and did a force push of the branch. |
# enable output to terminal | ||
zle -I | ||
# clear screen and move cursor to (0, 0) | ||
print -n "\e[2J\e[0;0H" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this use single-quotes? I kinda like to use single-quotes when there's no variable expansion going on to make the intent clear. Does that make sense? (I'm still not sure about it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single-quotes would work, no doubt. Although, when working with shell scripts I kind of prefer double quotes. It's easier to add a variable later (no need to convert quotes) and you don't really need to think about which to use. The exception I usually do is when you have double-quotes inside the string, then I might wrap it in single-quotes.
I'm fine with either as long as we stick to one way of doing it :)!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Let's stick with single-quotes wherever possible for now then. We can always change later if that feels weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I'll update the PR.
Tried it now. Works good. I always bothered me that the preprompt would disappear and I had no idea it was fixable :) |
Yeah, I was kind of bothered by it too, and if @zmwangx hadn't brought it up, I probably wouldn't have investigated it further, so thanks to him (and his input)! :) |
As discussed in #145 This PR fixes clear screen in pure (where the preprompt is missing when issuing Ctrl+L).
Due to third-party libraries doing whatever they want, I've decided to take a more fragile, but safer approach in this PR (see 4961520 for details).