Clear Your Terminal in Style

栏目: IT技术 · 发布时间: 5年前

内容简介:If you’re someone like me who habitually clears their terminal, sometimes you want a little excitement in your life. Here is a way to do just that.This post revolves around the idea of giving a command a percent chance of running. While the topic at hand i

If you’re someone like me who habitually 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 10 chance of do_this running, and a 9 in 10 chance of do_that running. You can omit || do_that to just have a 10 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 10% chance of the cbeams command running. When it runs, it will look like this:

Clear Your Terminal in Style

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'

Clear Your Terminal in Style

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'

Clear Your Terminal in Style

Extra: VT100 Files

Here’s a piece of terminal history. VT100 is a video terminal made in 1978. There are archives of animations made with this tool – some dating back more than 40 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:


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

用户故事与敏捷方法

用户故事与敏捷方法

Mike Cohn / 石永超、张博超 / 清华大学出版社 / 2010-4 / 39.00元

《用户故事与敏捷方法》详细介绍了用户故事与敏捷开发方法的结合,诠释了用户故事的重要价值,用户故事的实践过程,良好用户故事编写准则,如何搜集和整理用户故事,如何排列用户故事的优先级,进而澄清真正适合用户需求的、有价值的功能需求。 《用户故事与敏捷方法》对于软件开发人员、测试人员、需求分析师和管理者,具有实际的指导意义和重要的参考价值。一起来看看 《用户故事与敏捷方法》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具