Code Monkey home page Code Monkey logo

colorsh's Introduction

colorsh

A collection of variables to allow user Bash scripts to utilize color quickly and easily.

Installation

Source the SOURCEME file in your ~/.bashrc or ~/.bash_profile. The next time you start a CLI session, the color variables will be available.

# ~/.bashrc

source "/path/to/colorsh/SOURCEME"

# just for testing...
echo "${B}${COL_GREEN}Colors successfully sourced!${X}"

Users are encouraged to define their own variables using the basic variables defined by colorsh. You can include this collection of user-defined colors in a file named user.colors.sh in the root of the colorsh project directory (it's .gitignore-d). User colors are sourced AFTER colorsh colors to allow overrides.

Available Variables

  • $STYLE_BRIGHT - Makes CLI text "bold" or "bright" depending on your settings.
  • $STYLE_NORM - Resets to default CLI coloring and styling.
  • $STYLE_DIM - Makes CLI text "dim" depending on your settings.
  • $COL_BLACK
  • $COL_RED
  • $COL_GREEN
  • $COL_YELLOW
  • $COL_BLUE
  • $COL_MAGENTA
  • $COL_CYAN
  • $COL_WHITE
  • $BG_BLACK
  • $BG_RED
  • $BG_GREEN
  • $BG_YELLOW
  • $BG_BLUE
  • $BG_MAGENTA
  • $BG_CYAN
  • $BG_WHITE
  • $X - A shortcut for $STYLE_NORM
  • $B - A shortcut for $STYLE_BRIGHT
  • $D - A shortcut for $STYLE_DIM
  • $W - A style for warnings.
  • $E - A style for errors.

Notes

Colors override colors, and styles override styles. This means that you will not always need to include the ${X} variable before changing colors. Users should, however, explicitly reset styles in each individual string by including ${X} at the end.

#!/bin/bash

# creating your own variables with color
loud=${B}${COL_YELLOW}
echo "is there ${loud}anyone${X} who can hear me?"

# overriding
echo "${COL_MAGENTA}His name is ${COL_WHITE}John Smith${X}"

The great thing about these variables is that, if they aren't defined, they are treated as empty strings. No errors, no weird formatting, just the original text with no formatting. If the project changes or is missing, your scripts/applications won't break. They just won't be as pretty. =]

colorsh's People

Contributors

smolations avatar

Watchers

 avatar  avatar  avatar

Forkers

chriscorwin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.