Skip to content

Instantly share code, notes, and snippets.

@MrZoidberg
Last active February 2, 2018 11:20
Show Gist options
  • Save MrZoidberg/a14bf9114a77262f32d9db74d12f24e7 to your computer and use it in GitHub Desktop.
Save MrZoidberg/a14bf9114a77262f32d9db74d12f24e7 to your computer and use it in GitHub Desktop.
Help command for makefile with colored output
# 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