unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.73k stars 266 forks source link

Provide a way to clear the screen #3650

Closed stew closed 1 year ago

stew commented 1 year ago

It would be nice to have a clear command that would clear the screen similar to the familar /usr/bin/clear

Bonus points for making Ctrl+l work

hojberg commented 1 year ago

We might have something in haskell line we can use.

aryairani commented 1 year ago

I don't think there's a platform-independent way to clear the screen, it's a terminal-specific thing. e.g. In Terminal.app, you can clear the screen with Cmd-K (clears scrollback) or Ctrl-Cmd-L (preserves scrollback). /usr/bin/clear uses the terminfo database to figure out how.

Does Ctrl+L work for you in ucm currently outside of tmux?

I'm surprised that there's not a tmux command for clearing the buffer? At least, I haven't been able to find one that worked.

We could try clearing the screen with ANSI commands since we're already using ANSI commands.

stew commented 1 year ago

clearing the screen with ANSI is what I would do echo -e '\033[2J' should do it. If there is a way to detect the screen height, you can just emit that many blank lines. I suppose we could do something like less -cEFf /dev/null since we require less, but that seems extra janky

andreystepanov commented 3 months ago

Copy of my response on Discord, for those looking for how to make ctrl-l keybindings to work in ucm.

Since ucm uses haskeline under the hood, one can just define custom keybindings in ~/.haskeline config file (path on my Linux system).

Configuration is global, and would be used in ghci too, if you happen to write Haskell.

So here's how ctrl-l keybinding defined in the config:

bind: ctrl-l c l e a r return

Spaces between c l e a r characters are intentional, so keep them.

For more customization see Haskeline Wiki.