An open API service indexing awesome lists of open source software.

https://github.com/rcmachado/shell-utils

shell-utils is a collection of functions to make shell script development more fun and less repetitive.
https://github.com/rcmachado/shell-utils

Last synced: 3 months ago
JSON representation

shell-utils is a collection of functions to make shell script development more fun and less repetitive.

Awesome Lists containing this project

README

        

shell-utils - collection of useful shell helpers
================================================

[![Build Status](https://travis-ci.org/rcmachado/shell-utils.svg?branch=master)](https://travis-ci.org/rcmachado/shell-utils)

shell-utils is a collection of functions to make shell script
development more fun and less repetitive.

The main idea is to write small functions that are composable and
reusable - but have a use on its own. With this approach, we can make
a small but very efficient library.

![shell-utils example](/screenshot.png?raw=true "shell-utils screenshot")

Installation
------------

Clone this repository:

$ git clone https://github.com/rcmachado/shell-utils.git

And point `SHELL_UTILS_DIR` to `shell-utils` directory. See Usage for
details.

Usage
-----

Because there is no reliable way to identify the absolute path of a
variable, you need to set `SHELL_UTILS_DIR` with the dir that contains
the scripts. After that, just include `all.sh` on your script:

```sh
#!/bin/sh

# Supposing that you copied the libs into shell-utils directory
# relative to current script path

SHELL_UTILS_DIR="$(dirname $0)/shell-utils"
. $SHELL_UTILS_DIR/all.sh

# .. continue with your code ..

```

Look at `examples.sh` file to see how to use.

Documentation
-------------

### header.sh

* `print_separator N C`: print a separator line repeating char `C`
`N` times
* `print_header`: print a header title

### colors.sh

* `print_color "color name" "message"`: print `message` in `color name`

Aditionally to `print_color` function, there are also `COLOR_*`
variables with color codes for printing on shell.

### log.sh

* `log_debug`: print debug message
* `log_info`: print info message
* `log_warn`: print warning message
* `log_error`: print error message

License
-------

MIT license. Pull requests welcome :)