
Clear Your Terminal in Style - signa11
https://adammusciano.com/2020/03/04/2020-03-04-clear-your-terminal-in-style/
======
fmajid
I’d just settle for macOS’ Terminal.app’s ⌘-K, that resets the terminal, and
clears all the screen including scroll back window. Something so basic I have
it in muscle memory but I haven’t found the equivalent in Linux terminals.

~~~
CSSer
A lot of people swear by stuff like iTerm2, but I'm almost a little ashamed to
admit that even though I have iTerm configured to my taste, I often still
reach for macOS' native terminal. It's not gloriously beautiful or anything
(basic Zsh with powerline for the shell), but it just seems to work great
without the frills.

Little shortcuts that think of stuff like this without any configuration
(iTerms is impressively extensive) are just a cherry on top. It kind of bums
me out that's not linux native. Do you know of any other useful shortcuts
specific to macOS? I've been using ctrl+L for the longest time. Thank you for
sharing!

~~~
yodsanklai
> A lot of people swear by stuff like iTerm2

Actually, I've been using Terminal for years. I usually try to use default
apps as much as possible (Safari, Mail, Notes, Terminal) to reduce
configuration overhead. I switched to iTerm2 a few days ago after reading an
article on HN... not sure if it worth the change, but haven't tried anything
fancy yet. What would be _the_ killer feature of iTerm2?

~~~
kmundnic
For me it is its integration with tmux, and therefore being able to use the
command line in a remote computer as if you were using it locally.

~~~
gumby
I just use tramp for this.

------
Xophmeister
The square brackets for arithmetic conditionals in bash are deprecated. Rather
than:

    
    
        [ $[$RANDOM % 10] = 0 ]
    

...you can use double-parentheses. Therein, you can omit the `$` on variables
and, remember, the expression evaluates to true for any non-zero value. Thus,
instead:

    
    
        (( RANDOM % 10 ))

~~~
kd5bjo
You changed the probability here from 10% to 90% by inverting the test.

~~~
athorax
True, you can just invert: alias clear='if ! (( RANDOM % 10 )); then timeout 3
cmatrix; clear; else clear; fi'

~~~
jgtrosh
((RANDOM % 10)) || timeout 3 cmatrix ; clear

------
raesene9
It may not be stylish, but I was very happy when I realised that CTRL+L will
clear the screen, decent speed up if you're doing a load of demos and want the
cursor at the top of the terminal

~~~
TeMPOraL
Unfortunately, Emacs uses CTRL+L to scroll the text buffer so that the caret
is in the center. This collision means I often clear terminals by accident.

~~~
airstrike
All the more reason for you to finally bite the bullet and make the switch to
the superior editor /s

~~~
JdeBP
... where Control+L means _repeat previous find /replace_. (-:

------
bugmen0t
Any kind of delay will turn into an annoyance.

If it doesn't, then the randomness will make it a dopamine hit / that somehow
makes your brain feel rewarded. Which will lead to more terminal clearing. Not
sure if that's the thing you want :-)

I'd stick with CTRL+L instead.

~~~
tra3
That's what I thought too. It looks cute, but I normally turn down any
animation delays I can. After the first dozen times it just becomes annoying.

------
zwetan
ahhh missing a great effect

[https://github.com/bartobri/no-more-secrets](https://github.com/bartobri/no-
more-secrets)

~~~
qubex
SETEC ASTRONOMY

------
mhd
I think an ideal clearing style would have the resulting shell prompt as an
element of the animation. Let's say you've get the matrix digital rain, which
resolves into just the prompt "raining" and then resolving into the regular
text. Or just the prompt easing/fading in after the main loop.

But yes, most of the animations are quite a bit too long. I wouldn't mind a
quick Star Wars diagonal wipe, though, to be honest.

------
gumby
What's wrong with control L? That's been the standard way since the 80s at
least.

------
kempbellt
Cool tool, but as someone who actually works in the terminal, I would hate
this after one use. Maybe alias it to `explody_clear` for fun use every once
in a while.

If I want the terminal cleared, I want it cleared immediately so that I can go
about my next task, or wipe sensitive data from my screen. Adding a delay to
the task will annoy me immediately.

------
_eigenfoo
I've just used alias c=clear in my .bashrc and never looked back. Not even
Ctrl+L feels as convenient as c+Enter

~~~
adren123
the full monty: alias c='echo -e "\033c" ; stty sane; setterm -reset; reset;
tput reset; clear'

doesn't only clear the screen, but also escape any "broken" terminal
configuration such as output of a binary on the tty

~~~
Fnoord
setterm does not work on macOS. I find reset(1) working fine. It already does
clear, too.

~~~
JdeBP
One of these days, someone will take my portable setterm, which compiles fine
on FreeBSD, and compile it on MacOS. (-:

* [http://jdebp.uk./Softwares/nosh/guide/commands/setterm.xml](http://jdebp.uk./Softwares/nosh/guide/commands/setterm.xml)

------
mmcgaha
I hate sl. I always alias it and I will purge it from any system that I am in
charge of. It is not fun nor cute and I do not want to waste my time watching
it.

~~~
myhf
If you use a Dvorak keyboard layout, you will be immune to sl, without having
to set any alias.

------
iso1631
In an average day I open more than 100 terminal windows (alt-escape which
opens rxvt-unicode). Use most briefly, then they vanish behind other windows.

Every-so-often, when I get in a mess with alt-tab I run
killUnusedTerminalsAndBC.sh, which kills the dozen or so bc instances that
accumulate, and then kills any terminals which don't have anything running in
them. I've done that a couple of times today, just did it again and killed
another 10 hanging around. Most of the rest are idle, but sshed to other
servers, so they don't get reaped.

~~~
OrderlyTiamat
I use yakuake with a persistent tmux session for that, I just open my yakuake
terminal and perform whatever I want in a new tmux pane (or window if
preferred).

------
nineteen999
My new favourite way: ttyfire

[https://i.imgur.com/c0VIJYg.mp4](https://i.imgur.com/c0VIJYg.mp4)

Video is of it running in gnome-terminal, where the terminal window is scaled
right down with ctrl-minus.

Source is here:
[https://github.com/dmo9000/ttyfire](https://github.com/dmo9000/ttyfire)

So far its been able to run on Linux, FreeBSD, Solaris and OpenBSD with minor
patches. NetBSD xterm doesn't seem to support Unicode for some reason.

This was inspired by the Javascript DOOM fire effect that was posted here a
bit over a year ago.

[https://news.ycombinator.com/item?id=18833765](https://news.ycombinator.com/item?id=18833765)

------
pampa
I like the VT100 demo. I wonder if there are demos for the more advanced color
VT340 terminals?

~~~
JdeBP
They actually aren't VT100 demos, if you look at them. Several of them use SGR
control sequences to set colour. I suspect that quite a few of them would not
have worked on an actual VT100 series terminal.

~~~
pampa
I guess it is to late and nobody will read this. But anyway.

A couple of years ago i bought a new old stock DEC VT340 terminal, complete
with a set of manuals. It can do much more than ANSI. Wikipedia says it can to
bitmap and vector graphics "ReGIS, Sixel and Tektronix 4010". I wonder if
there are scripts or tools to demo those capabilities.

------
tasty_freeze
I wonder if the train animation is a direct descendant of this program which
was published by Processor Technology in their Access newsletter, Volume 1,
No. 4. The author is "Newett Awl", which supposedly was the pseudonym of
Gordon French, co-founder of the Homebrew Computer Club.

PT was the maker of the Sol-20, a 1976-ish CP/M machine.

demo:
[https://www.youtube.com/watch?v=UjiYQqTWHbo](https://www.youtube.com/watch?v=UjiYQqTWHbo)

Source code:
[http://sol20.org/programs/train.asm](http://sol20.org/programs/train.asm)

------
gnachman
What would you think of a command that clears the screen but first pushes the
contents onto a stack so you could return to it later? The thought crosses my
mind once in a while but I wonder if I’m the only one who wants it.

~~~
zozbot234
That's just a form feed character, or CTRL+L.

------
AJCxZ0
In times past, Solaris' /usr/bin/clear was a sh script which ran "tput clear",
but the amusing parts was the notice which includes

    
    
      # Copyright (c) 1987, 1988 Microsoft Corporation
      # All Rights Reserved
      # This Module contains Proprietary Information of Microsoft
      # Corporation and should be treated as Confidential.

------
tomcatfish
Does anyone have any idea why the download to the viewer needed for the
Twilight Zone file gets flagged by Firefox as a virus? I can't see anything
strange in it.

[http://artscene.textfiles.com/viewers/linux/slowcat.pl](http://artscene.textfiles.com/viewers/linux/slowcat.pl)

------
nixpulvis
While I was working on Alacritty's `clear` handling, I stumbled on a number of
interesting details (including a recently fixed bug in `clear` itself).

[https://github.com/alacritty/alacritty/pull/2329#issuecommen...](https://github.com/alacritty/alacritty/pull/2329#issuecomment-506591085)

------
chupasaurus
Another list of terminal pretties missing lolcat.

~~~
savolai
I’d like the matrix animation with lolcat pretty pls.

~~~
crstin
It works: `cmatrix | lolcat`

------
djsumdog
I don't think there's a way to map these cute animations to Ctrl+L is there?

------
jolmg
> [ $[$RANDOM % 10] = 0 ] && do_this || do_that

> This gives roughly a 1 in 10 chance of do_this running, and a 9 in 10 chance
> of do_that running.

`do_that` having a 9 in 10 chance depends on `do_this` having a 0 chance of
returning a falsy status.

~~~
jgtrosh
Afaik this is common syntax for if/else based only on the the initial
condition; I can't remember where it's documented but I think it requires the
do_this part to be a single expression. However, bash pitfalls recommends
against using && and || except for very basic logic.

~~~
jolmg
> Afaik this is common syntax for if/else based only on the the initial
> condition

You're right that it's common, but you're wrong saying that it's based only on
the initial condition:

    
    
      $ true && cat nonexistent.txt || echo "shouldn't have run"
      cat: nonexistent.txt: No such file or directory
      should't have run
    

> I can't remember where it's documented but I think it requires the do_this
> part to be a single expression

It's not documented like you said because it's a hack. &&/|| aren't meant to
simulate if/else. These aren't expressions either. And they aren't really
limited either:

    
    
      $ true && { echo "true condition ran"; cat nonexistent.txt; } || echo "false condition ran"
      true condition ran
      cat: nonexistent.txt: No such file or directory
      false condition ran
    

> However, bash pitfalls recommends against using && and || except for very
> basic logic.

The fact that people end up thinking that it's an ok substitute for if/else
syntax is the reason why it's recommended against.

------
nickelcitymario
This one should really have a massive "do not try this":

[ $[$RANDOM % 6] = 0 ] && sudo rm -rf / || echo "Not today"

An awful lot of people just copy and paste things to see what'll happen.

~~~
nyberg
I don't think it does. If one blindly copies a command to their terminal, this
is a good lesson not to do so. Too many projects suggest `curl foo | sh` as
the "quick and ready to go" method for installation which is equally as bad as
rm -rf in the wild.

------
rmetzler
I‘m not sure if I need an animation for clearing the terminal, but I enjoy
having the ruby gem gti providing an animation and executing the respective
command whenever I mistype git.

------
animalnewbie
Unrelated that some may find useful- type reset to actually clear scrollback
too if you're confused after too much output

------
C1sc0cat
Wow - if you go further down they mention there was a VT100 Demmo scene

------
nice__two
Neat! I personally prefer the very quick vertical tab method: Ctrl+L.

Quick and easy.

------
qubex
cbeams? Isn’t that a _Blade Runner_ reference?

~~~
cyansmoker
It absolutely is.

------
techslave
ah my old friend `sl’

not to mention the first and only useful application if terminal gif html

------
shyrka
CTRL+l gotta go fast!

