Advertisement
svenhoefer

Untitled

Nov 17th, 2018
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.40 KB | None | 0 0
  1. # $(1) = title; $(2) = color
  2. define draw_line
  3.     @ \
  4.     printf '%.0s-' {1..$(shell tput cols)}; \
  5.     if test "$(1)"; then \
  6.         cols=$(shell tput cols); \
  7.         length=$(shell echo $(1) | awk '{print length}'); \
  8.         let indent="cols - (cols - length) / 2"; \
  9.         tput cub $$indent; \
  10.         test "$(2)" && printf $$(tput setaf $(2)); \
  11.         printf '$(1)'; \
  12.         test "$(2)" && printf $$(tput sgr0); \
  13.     fi; \
  14.     echo
  15. endef
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement