mix-test.watch
mix-test.watch copied to clipboard
Update `maybe_clear_terminal` to remove scrollback
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 😅
Steps to test:
- Add
{:mix_test_watch, git: "git://github.com/codeOfRobin/mix-test.watch", only: :dev, runtime: false},
to yourmix.exs
. - Run
mix test.watch
and try making a few changes - You shouldn't have your scrollback anymore in Terminal
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: https://github.com/elixir-lang/elixir/pull/10030
Perhaps there could be a second config like config :mix_test_watch, clear_scrollback: <option>
, where option
could be :macos_terminal
, :macos_iterm
, any random escape sequence, nil
, or false
? (And if there were other common escape sequences, they could be added as options?)
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
https://github.com/lpil/mix-test.watch/pull/145