Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #!/bin/bash
  2. ## Specify color to write in using arguments
  3.  
  4. function --help {
  5. cat << EOF
  6.  
  7. ERROR: $0 requires a color argument.
  8.  
  9. USAGE: Changes the color of the text piped into it.
  10.  
  11. These color arguments are availabe:
  12.  
  13. ARGUMENT SHORTCUT
  14. white ------ w
  15. red ------ r
  16. green ------ g
  17. yellow ------ y
  18. blue ------ b
  19. violet ------ v
  20. teal ------ t
  21.  
  22. bold ------ bb
  23.  
  24. The "bold" argument will modify any color.
  25. Use a max of 2 arguments (one color and bold).
  26.  
  27. EOF
  28. }
  29.  
  30. function bold {
  31. # make the color bold
  32. BOLD=1;
  33. }
  34.  
  35. function white {
  36. COLOR=1
  37. }
  38.  
  39. function red {
  40. COLOR=31
  41. }
  42.  
  43. function green {
  44. COLOR=32
  45. }
  46.  
  47. function yellow {
  48. COLOR=33
  49. }
  50.  
  51. function blue {
  52. COLOR=34
  53. }
  54.  
  55. function violet {
  56. COLOR=35
  57. }
  58.  
  59. function teal {
  60. COLOR=36
  61. }
  62.  
  63.  
  64. ## shortcuts
  65. function bb {
  66. bold
  67. }
  68. function w {
  69. white
  70. }
  71. function r {
  72. red
  73. }
  74. function g {
  75. green
  76. }
  77. function y {
  78. yellow
  79. }
  80. function b {
  81. blue
  82. }
  83. function v {
  84. violet
  85. }
  86. function t {
  87. teal
  88. }
  89. function o {
  90. red
  91. bold
  92. }
  93.  
  94. ## Execution
  95.  
  96. if [ "$#" = 0 ]
  97. then
  98. --help
  99. fi
  100.  
  101. while (($#));
  102. do
  103. $1
  104. shift
  105. done
  106.  
  107. echo -n "["$BOLD""$COLOR"m"
  108. cat
  109. echo -n "[0m"
  110.  
  111. $ infocmp | grep colors
  112. colors#256, cols#80, it#8, lines#24, pairs#256,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement