Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/bashly/libraries/colors/colors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
## Color output will be disabled if `NO_COLOR` environment variable is set
## in compliance with https://no-color.org/
##
## In case you wish to enable auto detection for color output based on the
## terminal being interactive (TTY), call `enable_auto_colors` in your
## `src/initialize.sh` (Run `bashly add hooks` to add this file).
##
enable_auto_colors() {
[[ -z ${NO_COLOR+x} && ! -t 1 ]] && NO_COLOR=1 || true
}

print_in_color() {
local color="$1"
shift
Expand Down
8 changes: 8 additions & 0 deletions lib/bashly/libraries/libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ colors:
files:
- source: "colors/colors.sh"
target: "%{user_lib_dir}/colors.%{user_ext}"
post_install_message: |
The colors library supports the g`NO_COLOR` standard out of the box.

In case you wish to also enable automatic output of colors based on the
terminal being interactive (TTY), call g`enable_auto_colors` in your
g`src/initialize.sh`. You may run the following command to add this file:

m`$ bashly add hooks`

completions:
help: Generate a bash completions function.
Expand Down
Loading