/bash-utils

Bash - utils function

Primary LanguageShellMIT LicenseMIT

Bash utils

Table of Contents

Getting Started

Import

Import all the libararies:

source /path/to/bash-utils/all.sh

Import single LIBRARY:

source /path/to/bash-utils/lib/${LIBRARY}

Libraries

chalk

Output styled message. See chalk.sh for further details and predined chalk.<style> shortcuts.

# chalk [<style>] [<message>]
# @param <style := $NO_COLOR> The style to apply to the <message>
# @param <message := ''>      The message
chalk $YELLOW "Message in yellow color."

# chalk.<style> functions
chalk.RED "Message in red color."

colors

Define ANSI color escape codes See colors.sh for further details and predefined colors.

# color <ansi_color_code>
# @param <ainsi_color_code> The ANSI color code
RED=$( color "0;31" )

log

Log a message with an appropriate colorized level See log.sh for further details and predefined log.<level> shortcuts.

# log [<level>] [<message>]
# @param <level := ''>    The log level
# @param <message := ''>  The log message
log --info "Info message."
log.info "Info message."

root_path

Resolve the root path from a bash script. See root_path.sh for further details.

# root_path <source>
# @param <source> The bash source invokation
ROOT_PATH=$( root_path ${BASH_SOURCE[0]} )

FAQ

License

See LICENSE file