_xhr_,
@_xhr_@cybervillains.com avatar

TIL that you can redirect clear(1)'s standard output to a file and the use cat on the file to clear the screen.

$ clear > foo
$ cat foo

#unix #bsd #linux #openbsd

hexehelicen,
@hexehelicen@social.tchncs.de avatar

@_xhr_
does that mean that it is a special output character, like color ?

Wow, just tried it, it seems to be
^ [ H ^[ 2 J ^[ 3 J

cmdrmoto,
@cmdrmoto@hachyderm.io avatar

@hexehelicen @_xhr_ ANSI vs VT100 vs (etc) don’t all agree on what sequence to use.

The “clear” utility queries your $TERM environment variable to decide which control sequence to print.

In other words, this is neat, but not necessarily portable across terminal protocols

apodoxus,
@apodoxus@mastodon.online avatar

@_xhr_

$ clear > /tmp/foo
$ xxd /tmp/foo
00000000: 1b5b 481b 5b32 4a1b 5b33 4a .[H.[2J.[3J

_xhr_,
@_xhr_@cybervillains.com avatar

@apodoxus hehe, i used hexdump and did exactly the same :)

apodoxus,
@apodoxus@mastodon.online avatar

@_xhr_ It seems like 1B is the escape. I never paid attention to this before..

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux
  • DreamBathrooms
  • mdbf
  • InstantRegret
  • Durango
  • Youngstown
  • rosin
  • slotface
  • thenastyranch
  • osvaldo12
  • ngwrru68w68
  • kavyap
  • cisconetworking
  • khanakhh
  • magazineikmin
  • provamag3
  • cubers
  • vwfavf
  • modclub
  • everett
  • ethstaker
  • Leos
  • tacticalgear
  • normalnudes
  • tester
  • GTA5RPClips
  • anitta
  • megavids
  • JUstTest
  • All magazines