Hiya folks, As a learning project to teach myself how to use the ksh shell I wrote a helper script to set ansi colors and decorations that I'm calling *kshcolor*.
The script is available here for anyone who is intrigued: https://github.com/tbullock/kshcolor The project includes a makefile to build the script, this was necessary since manually typing ANSI escape sequences is annoying so I chose to generate those rather than fail at typing them. To install run `make install` To run the included test run `make test` The makefile will install the file kshcolor.sh in $(HOME)/bin The script includes the following functions: bk # Sets Black rd # Sets Red gr # Sets Green ye # Sets Yellow bl # Sets Blue mg # Sets Magenta cy # Sets Cyan wh # Sets White bg_bk # Sets background Black bg_rd # Sets background Red bg_gr # Sets background Green bg_ye # Sets background Yellow bg_bl # Sets background Blue bg_mg # Sets background Magenta bg_cy # Sets background Cyan bg_wh # Sets background White bold # Bold dim # Dim underline # Underline blink # Blink (this may not be implemented by your terminal) invert # Invert hidden # Hidden reset_decorations # clear inherited decorations These functions do not directly make any visible changes to the terminal, rather that is left to the function: decorate # applies configured decorations to the first argument The decorate function looks at the currently configured decorations (colours and attributes) and applies the necessary ANSI escape sequences to tell the terminal how it's argument is to be rendered. If the terminal doesn't support at least the standard 8 ANSI colours this become a no-op and leaves the variable undecorated. The result can then be sent to echo or print or wherever your heart desires them to go (maybe Narnia!?). Example: # Apply foreground and background colours separately rd bg_ye text1=$(decorate "this text is red ") # Change the background colour bg_mg text2=$(decorate "but the background changes") # Display the decorated text echo "${text1}${text2}" reset_decorations This project was largely an educational evening for me in how ksh scripting works, if people find it useful, cute or want to use it to splash the rainbow all over their terminal, then please let me know what you come up with.

