Bash - Fun Shell

Good news: my blog has been opened. Many other blogs please go to http://swplzj.github.io

Had some free time today Shell. Found a few interesting ones. Record it.

  • Terminal rainbow word:lolcat
  • Graphical text:figlet
  • Lucky life motto:fortune
  • ASCIICow said:Cowsay
  • Waterfall text in The Matrix:cmatrix
  • write at the end

Very interesting Shelland worth a try;

lolcat

Install

Because Lolcatis a ruby gemprogram, you must have the latest version number installed on your system ruby.

The installation rubyprocess is no longer detailed;

Install using the following commandlolcat

gem install lolcat

use

lolcatThe effect is to add a rainbow of colors to the text in the terminal. It can be used after installation.

First look at lolcatthe help documentation

lolcat --help

Then check the calendar

cal | lolcat

Advanced Tips

We are also able to animate the text with rainbow colors:

echo Hello World | lolcat -a -d 500

Aliases trick:alias

We found that if a frequently used print command, for example , wants to print rainbow colors, we need to add it after lstyping each time . That is , it is very inconvenient. Then we can think of aliases, . We can set some aliases:lslolcatls | lolcatalias

alias ls="ls | lolcat"

But. There is a problem. Just close the terminal tab or restart the terminal. The alias we set is invalid, which means that the alias is only valid for the current tab.

So, next we have to set it to be aliaspermanent. We enter the command cd ~to the user home folder and find the .bash_profilefile. Assuming no. we create a

touch .bash_profile

Then .bash_profileadd our alias in

alias ls="ls | lolcat"  

Save, close, restart Terminal, and see the effect:

BTW

If your terminal does not have a color scheme set, you can choose the theme that comes with it: Silver Aerogel, setting method: find .bash_profilethe file, and add the following code, for example:

# for color
export CLICOLOR=1
# \h:\W \u\$
export PS1='\[\033[01;33m\]\u@\h\[\033[01;31m\] \W\$\[\033[00m\] '

Save it, restart the terminal, and you should be able to see the beautiful color scheme.

figlet

Install

We use Homebrewto install this plugin,

brew install figlet

use

  • figlet
lizhenjie@localhost ~$ figlet Leo Lee
 _                 _              
| |    ___  ___   | |    ___  ___ 
| |   / _ \/ _ \  | |   / _ \/ _ \
| |__|  __/ (_) | | |__|  __/  __/
|_____\___|\___/  |_____\___|\___|
  • figlist: list all font names
lizhenjie@localhost ~$ figlist
Default font: standard
Font directory: /usr/local/Cellar/figlet/2.2.5/share/figlet/fonts
Figlet fonts in this directory:
3-d
3x5
5lineoblique
acrobatic
alligator
alligator2
alphabet
...
  • showfigfonts: Show each font effect.
lizhenjie@localhost ~$ showfigfonts
3-d :
  ****             **
 */// *           /**
/    /*           /**
   ***  *****  ******
  /// */////  **///**
 *   /*      /**  /**
/ ****       //******
 ////         ////// 


3x5 :

###     ### 
  # # # #   
 ##  #  ### 
  # # #   # 
###     ### 
...

Only two fonts can be listed. Too much.

Of course, it is even more dazzling to be able lolcatto .

Dashboard Figlet

During the installation process, it was unexpectedly found Figletthat there are also Dashboardplugins in . It can be downloaded from Apple's official website . It is also very convenient to use.

fortune

Install

brew install fortune

Instructions

lizhenjie@localhost ~$ fortune
"To take a significant step forward, you must make a series of finite 
improvements."
-- Donald J. Atwood, General Motors

Use in combination lolcatwith:

lizhenjie@localhost ~$ fortune | lolcat

Cowsay

Install

brew install cowsay

Instructions

  • cowsayBe able to output a calf in ASCII at the terminal, and the calf will say what you want it to say.

lizhenjie@localhost ~$ cowsay God help them who help themselves!
 ____________________________________ 
< God help them who help themselves! >
 ------------------------------------ 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
lizhenjie@localhost ~$ 
  • List all animal shapes that can be drawn
lizhenjie@localhost ~$ cowsay -l
Cow files in /usr/local/Cellar/cowsay/3.03/share/cows:
beavis.zen bong bud-frogs bunny cheese cower daemon default dragon
dragon-and-cow elephant elephant-in-snake eyes flaming-sheep ghostbusters
head-in hellokitty kiss kitty koala kosh luke-koala meow milk moofasa moose
mutilated ren satanic sheep skeleton small sodomized stegosaurus stimpy
supermilker surgery telebears three-eyes turkey turtle tux udder vader
vader-koala www
  • Use other animal shapes
lizhenjie@localhost ~$ cowsay -f dragon LEO
 _____ 
< LEO >
 ----- 
      \                    / \  //\
       \    |\___/|      /   \//  \\
            /0  0  \__  /    //  | \ \    
           /     /  \/_/    //   |  \  \  
           @_^_@'/   \/_   //    |   \   \ 
           //_^_/     \/_ //     |    \    \
        ( //) |        \///      |     \     \
      ( / /) _|_ /   )  //       |      \     _\
    ( // /) '/,_ _ _/  ( ; -.    |    _ _\.-~        .-~~~^-.
  (( / / )) ,-{        _      `-.|.-~-.           .~         `.
 (( // / ))  '/\      /                 ~-. _ .-~      .-~^-.  \
 (( /// ))      `.   {            }                   /      \  \
  (( / ))     .----~-.\        \-'                 .~         \  `. \^-.
             ///.----..>        \             _ -~             `.  ^-`  ^-_
               ///-._ _ _ _ _ _ _}^ - - - - ~                     ~-- ,.-~
                                                                  /.-~
  • fortuneuse in combination
lizhenjie@localhost ~$ fortune | cowsay
 _________________________________________ 
/ We are all worms. But I do believe I am \
| a glowworm.                             |
|                                         |
\ -- Winston Churchill                    /
 ----------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
  • Use in combination lolcatwith:

  • combinelolcat + fortune + cowsay

Isn't it amazing! ! .

cmatrix

Install

Vivid footage of The Matrix 'Hacker' style desktop

brew install cmatrix

Instructions

cmatrix 

Other usage methods can use manView .

write at the end

The above command may not be of much use to itself in practice, however. In the process of configuration, I learned a lot of things, and also added Shellmy understanding and interest in . We should not only limit ourselves to writing code, but let ourselves know more about what we don’t understand. Go out of your comfort zone from time to time, find something fun and challenging to do, and in short, make sure you keep improving. come on!

Good news: my blog has been opened. Many other blogs please go to http://swplzj.github.io

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324610708&siteId=291194637
Recommended