in ,

Clear Your Terminal in Style, Hacker News

        

            

                

If you’re someone like me who usuallyually clears their terminal, sometimes you want a little excitement in your life. Here is a way to do just that.

Percent Chance for command to run

This post revolves around the idea of ​​giving a command a percent chance of running. While the topic at hand is not serious, this simple technique has potential in your scripts.

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

This gives roughly a 1 in (chance of do_this running, and a 9 in 16 chance of do_that running. You can omit || do_that to just have a percent chance of do_this running.

Like Russian roulette?

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

Cbeams

Jonathan Hartley (tartley on GitHub), creater of the popular colorama python module, also made a cool little terminal application tool called cbeams. We can use his animation with a little bit of bash goodness to clear our terminal.

pip install cbeams

This is the animation command, which overwrites the current text on the terminal:

cbeams -o

To attach it to clear, we extend the command’s functionality:

alias clear='[ $[$RANDOM % 10]=0] && timeout 6 cbeams -o; clear || clear '

This way, there is a 40% chance of the cbeams command running. When it runs, it will look like this:

     SL)

The SL command stands for steam locomotive. It came about because of how often people mistype ls. Instead of this use, how nice would it be if a train ran the error logs you’re getting off the screen!

sudo apt install sl

alias clear='[ $[$RANDOM % 10]=0] && sl; clear || clear '

    

Cmatrix

The cmatrix command is based off the digital rain animation from the opening scenes of Matrix movie series.

sudo apt install cmatrix

alias clear='[ $[$RANDOM % 10]=0] && timeout 3 cmatrix; clear || clear '

    

Here’s a piece of terminal history. VT

is a video terminal made in 1978. There are archives of animations made with this tool – some dating back more than 80 years ago. They are a lot of fun to look back on. I can’t imagine how much time it took to make some of these. Take a look at a large archive from here . They also provide a perl script which allows you to view the files at the speed they were meant to be seen, here .

Here is a recording of a twilight zone animation I found particularly impressive:

      Your browser does not support the video tag.   

                

             

(Read More)

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

Figma – SwiftUI Inspector | SwiftUI inspector is here. Enhance your development workflow by copying and pasting element style …, Hacker News

Figma – SwiftUI Inspector | SwiftUI inspector is here. Enhance your development workflow by copying and pasting element style …, Hacker News

Galaxy S20 teardown shows off plethora of cameras, double-decker motherboard, Ars Technica

Galaxy S20 teardown shows off plethora of cameras, double-decker motherboard, Ars Technica