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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update maybe_clear_terminal
to remove scrollback
#120
base: master
Are you sure you want to change the base?
Conversation
`IO.ANSI.clear` + `home` seem to not clear scrollback (atleast on macOS), i.e. it prints "one screen height" of blank space and resets the cursor to the first position. A little bit of digging through [ANSI escape codes](https://askubuntu.com/questions/25077/how-to-really-clear-the-terminal) led me to this solution. I'm not sure if this is the best approach/if there's a way to get the right sequence out from the `IO.ANSI` library.
Steps to test:
|
@@ -2,6 +2,8 @@ defmodule MixTestWatch.Runner do | |||
@moduledoc false | |||
|
|||
alias MixTestWatch.Config | |||
|
|||
@clear_ansi_escape_sequence "\x1bc" |
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.
This didn't work for me on macOS in iTerm2 until I changed it to \e[2J\e[3J\e[H
.
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.
Strange 馃 maybe this is one of those things that is terminal emulator dependent?
I opened #136 yesterday, and then I noticed this PR. Is this still open because the project is stale or because the ANSI sequence does not work on all terminals? For me, this works: clear && printf '\e[3J' which should be: IO.puts(IO.ANSI.clear() <> "\e[3J") in Elixir. What can we do to have this PR merged? Another possible issue with the PR may be that not everyone wants their scroll-back cleared. This could be addressed with a configuration option. cc @lpil could we get some guidance? Are you accepting contributions? |
I noticed that IO.ANSI isn't going to support clearing scrollback: elixir-lang/elixir#10030 Perhaps there could be a second config like |
I created a new PR that allows you to specify the ANSI sequence for clearing the scrollback buffer, along with two presets: :macos_terminal and :macos_iterm2 |
IO.ANSI.clear
+home
seem to not clear scrollback (atleast on macOS), i.e. it prints "one screen height" of blank space and resets the cursor to the first position. A little bit of digging through ANSI escape codes led me to this solution.PS: I'm not sure if this is the best approach/if there's a way to get the right sequence out from the
IO.ANSI
library, I'm still an Elixir beginner 馃槄