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.
- Host: GitHub
- URL: https://github.com/rcmachado/shell-utils
- Owner: rcmachado
- License: mit
- Created: 2014-11-27T18:38:52.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-07-21T23:16:48.000Z (almost 10 years ago)
- Last Synced: 2023-03-11T05:44:41.152Z (about 2 years ago)
- Language: Shell
- Size: 227 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
shell-utils - collection of useful shell helpers
================================================[](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.
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 pathSHELL_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 messageLicense
-------MIT license. Pull requests welcome :)