Shell script (strict terminal format control, beautiful output font color)
[Cpp] view plaincopy
- #! /Bin/bash
- #
- # The following figure shows the font output color and terminal format control.
- # Font color 30-37
- Echo-e "\ 033 [30 m black character \ 033 [0 m"
- Echo-e "\ 033 [31 m red \ 033 [0 m"
- Echo-e "\ 033 [32 m green word \ 033 [0 m"
- Echo-e "\ 033 [33 m yellow \ 033 [0 m"
- Echo-e "\ 033 [34 m blue \ 033 [0 m"
- Echo-e "\ 033 [35m purple word \ 033 [0 m"
- Echo-e "\ 033 [36 m sky blue character \ 033 [0 m"
- Echo-e "\ 033 [37m white \ 033 [0 m"
- # Background color range: 40-47
- Echo-e "\ 033 [40; 37 m black white \ 033 [0 m"
- Echo-e "\ 033 [41; 30 m black text \ 033 [0 m"
- Echo-e "\ 033 [42; 34m green bottom blue \ 033 [0 m"
- Echo-e "\ 033 [43; 34m yellow bottom blue \ 033 [0 m"
- Echo-e "\ 033 [44; 30 m blue background black letter \ 033 [0 m"
- Echo-e "\ 033 [45; 30 m black character \ 033 [0 m"
- Echo-e "\ 033 [46; 30 m dark blue \ 033 [0 m"
- Echo-e "\ 033 [47; 34m white background blue \ 033 [0 m"
- #.....
- # Control options
- # \ 033 [close all properties at 0 m
- # \ 033 [1 m to set high brightness
- # \ 033 [4 m underline
- Echo-e "\ 033 [4; 31 m underline red letter \ 033 [0 m"
- # Flashing
- Echo-e "\ 033 [5; 34m red letter flashing \ 033 [0 m"
- # Shadow
- Echo-e "\ 033 [8 m blanking \ 033 [0 m"
- #
- # \ 033 [30 m-\ 033 [37m set foreground color
- # \ 033 [40 m-\ 033 [47m Set background color
- # \ 033 [move the nA cursor up n rows
- # \ 033 [move the nB cursor down n rows
- Echo-e "\ 033 [move the 4A cursor up 4 rows \ 033 [0 m"
- # \ 033 [right shift of nC cursor n rows
- # \ 033 [nD cursor shifts n rows left
- # \ 033 [y; xH: Set the cursor position
- # \ 033 [2J clear screen
- # \ 033 [K clear content from cursor to end of line
- Echo-e "\ 033 [K clear content from the cursor to the end of the line \ 033 [0 m"
- # \ 033 [s Save the cursor position
- # \ 033 [u restore cursor position
- # \ 033 [? 25 | hide the cursor
- # \ 033 [? 25 h show cursor
- Echo-e "\ 033 [? 25l hide cursor \ 033 [0 m"
- Echo-e "\ 033 [? 25 h show cursor \ 033 [0 m"
- # The following example shows that the font keeps flashing.
- #! /Bin/bash
- #
- A = 30
- B = 41
- Whiletrue
- Do
- Echo-e "\ 033 [$ {a} m glorious girl \ 033 [0 m"
- Echo-e "\ 033 [$ {a} m? West Asia \ 033 [0 m"
- Echo-e "\ 033 [$ {a} m locksass \ 033 [0 m"
- A = $ ($ a % 7) + 30 ))
- B = $ ($ B % 7) + 40 ))
- # Convert the font color at 30-37 each time
- # Convert the background color to 40-47 each time
- Echo-e "\ 033 [4A \ 033 [0 m"
- Done