Last active
February 2, 2018 11:20
-
-
Save MrZoidberg/a14bf9114a77262f32d9db74d12f24e7 to your computer and use it in GitHub Desktop.
Help command for makefile with colored output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Needed SHELL since I'm using zsh | |
SHELL := /bin/bash | |
.PHONY: help | |
help: ## This help dialog. | |
@IFS=$$'\n' ; \ | |
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \ | |
printf "%-30s %s\n" "target" "help" ; \ | |
printf "%-30s %s\n" "------" "----" ; \ | |
for help_line in $${help_lines[@]}; do \ | |
IFS=$$':' ; \ | |
help_split=($$help_line) ; \ | |
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \ | |
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \ | |
printf '\033[36m'; \ | |
printf "%-30s %s" $$help_command ; \ | |
printf '\033[0m'; \ | |
printf "%s\n" $$help_info; \ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment