Shell script (strict terminal format control, beautiful output font color)

Source: Internet
Author: User
Tags set background

Shell script (strict terminal format control, beautiful output font color)
[Cpp] view plaincopy

  1. #! /Bin/bash
  2. #
  3. # The following figure shows the font output color and terminal format control.
  4. # Font color 30-37
  5. Echo-e "\ 033 [30 m black character \ 033 [0 m"
  6. Echo-e "\ 033 [31 m red \ 033 [0 m"
  7. Echo-e "\ 033 [32 m green word \ 033 [0 m"
  8. Echo-e "\ 033 [33 m yellow \ 033 [0 m"
  9. Echo-e "\ 033 [34 m blue \ 033 [0 m"
  10. Echo-e "\ 033 [35m purple word \ 033 [0 m"
  11. Echo-e "\ 033 [36 m sky blue character \ 033 [0 m"
  12. Echo-e "\ 033 [37m white \ 033 [0 m"
  13. # Background color range: 40-47
  14. Echo-e "\ 033 [40; 37 m black white \ 033 [0 m"
  15. Echo-e "\ 033 [41; 30 m black text \ 033 [0 m"
  16. Echo-e "\ 033 [42; 34m green bottom blue \ 033 [0 m"
  17. Echo-e "\ 033 [43; 34m yellow bottom blue \ 033 [0 m"
  18. Echo-e "\ 033 [44; 30 m blue background black letter \ 033 [0 m"
  19. Echo-e "\ 033 [45; 30 m black character \ 033 [0 m"
  20. Echo-e "\ 033 [46; 30 m dark blue \ 033 [0 m"
  21. Echo-e "\ 033 [47; 34m white background blue \ 033 [0 m"
  22. #.....
  23. # Control options
  24. # \ 033 [close all properties at 0 m
  25. # \ 033 [1 m to set high brightness
  26. # \ 033 [4 m underline
  27. Echo-e "\ 033 [4; 31 m underline red letter \ 033 [0 m"
  28. # Flashing
  29. Echo-e "\ 033 [5; 34m red letter flashing \ 033 [0 m"
  30. # Shadow
  31. Echo-e "\ 033 [8 m blanking \ 033 [0 m"
  32. #
  33. # \ 033 [30 m-\ 033 [37m set foreground color
  34. # \ 033 [40 m-\ 033 [47m Set background color
  35. # \ 033 [move the nA cursor up n rows
  36. # \ 033 [move the nB cursor down n rows
  37. Echo-e "\ 033 [move the 4A cursor up 4 rows \ 033 [0 m"
  38. # \ 033 [right shift of nC cursor n rows
  39. # \ 033 [nD cursor shifts n rows left
  40. # \ 033 [y; xH: Set the cursor position
  41. # \ 033 [2J clear screen
  42. # \ 033 [K clear content from cursor to end of line
  43. Echo-e "\ 033 [K clear content from the cursor to the end of the line \ 033 [0 m"
  44. # \ 033 [s Save the cursor position
  45. # \ 033 [u restore cursor position
  46. # \ 033 [? 25 | hide the cursor
  47. # \ 033 [? 25 h show cursor
  48. Echo-e "\ 033 [? 25l hide cursor \ 033 [0 m"
  49. Echo-e "\ 033 [? 25 h show cursor \ 033 [0 m"
  50. # The following example shows that the font keeps flashing.
  51. #! /Bin/bash
  52. #
  53. A = 30
  54. B = 41
  55. Whiletrue
  56. Do
  57. Echo-e "\ 033 [$ {a} m glorious girl \ 033 [0 m"
  58. Echo-e "\ 033 [$ {a} m? West Asia \ 033 [0 m"
  59. Echo-e "\ 033 [$ {a} m locksass \ 033 [0 m"
  60. A = $ ($ a % 7) + 30 ))
  61. B = $ ($ B % 7) + 40 ))
  62. # Convert the font color at 30-37 each time
  63. # Convert the background color to 40-47 each time
  64. Echo-e "\ 033 [4A \ 033 [0 m"
  65. Done

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.