Skip to content
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

Clearing the buffer without clearing the status line #676

Closed
corazzi opened this issue May 28, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@corazzi
Copy link

commented May 28, 2019

Basically, when you clear the buffer with Cmd + K, since the status line is printed above the actual prompt, it also gets cleared. This doesn't, however, happen with a simple clear.

I'm hoping someone has a clever way to get around this. So far I've been clearing the buffer then clearing normally immediately after, but it's not ideal.

Environment

Spaceship version: 3.10.0
Zsh version: zsh 5.3 (x86_64-apple-darwin17.0)
Zsh framework: oh-my-zsh
Zsh plugin manager: None
Terminal emulator: iTerm
Operating system: macOS

Demonstration

Imgur

@laggardkernel

This comment has been minimized.

Copy link
Contributor

commented May 28, 2019

Firstly, your problem has nothing to do with this prompt theme. I don't understand why you opened a issue here.

Clear Buffer with Cmd + K is a terminal function exclusive to iTerm. It's implemented by the terminal to delete the history output.

While clear means clear screen and it just hides the content to the top, which is implemented by the shell.

If you only need a key binding to clear the screen, try Ctrl-L. If it doesn't work, use this

bindkey "^L" clear-screen
@corazzi

This comment has been minimized.

Copy link
Author

commented May 29, 2019

It is related to the prompt theme. I'm not saying it's an issue with the theme, but my issue is because of the theme.

With spaceship prompt, the status line is printed above the prompt as a separate line. When you clear the buffer, it clears the status line.

I understand the difference between clearing the buffer and clear. Thank you for your explanation, though.

I was wondering if anybody had a workaround for this, whilst still clearing the buffer. Simply clearing the screen is not enough. That is why I opened this support request.

Thanks for your time.

@laggardkernel

This comment has been minimized.

Copy link
Contributor

commented May 29, 2019

function clear-scrollback-buffer {
  clear
  printf '\e[3J'   
  zle -I
}

zle -N clear-scrollback-buffer
bindkey '^L' clear-scrollback-buffer
@corazzi

This comment has been minimized.

Copy link
Author

commented May 29, 2019

That's a great solution, thanks @laggardkernel :)

@corazzi corazzi closed this May 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.