Created
December 6, 2013 16:59
-
-
Save davidh-raybeam/7828262 to your computer and use it in GitHub Desktop.
bar usage: bar foo
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
#! /usr/bin/env ruby | |
bar_char = '-' | |
lead_count = 5 | |
cols = `tput cols`.strip.to_i | |
max_len = [cols - ((2 * lead_count) + 4), 0].max | |
bar_color = `tput setaf 3` | |
reset = `tput sgr0` | |
title = ARGV.join ' ' | |
title = title[0...max_len] | |
title = "[ #{title} ]" unless title == "" | |
print bar_color | |
print bar_char * [lead_count, cols].min | |
print title | |
print bar_char * [cols - title.length - lead_count, 0].max | |
print reset | |
print "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment