Skip to content

Instantly share code, notes, and snippets.

@davidh-raybeam
Created December 6, 2013 16:59
Show Gist options
  • Save davidh-raybeam/7828262 to your computer and use it in GitHub Desktop.
Save davidh-raybeam/7828262 to your computer and use it in GitHub Desktop.
bar usage: bar foo
#! /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