Skip to content

Instantly share code, notes, and snippets.

@acook
Last active December 10, 2015 05:18
Show Gist options
  • Save acook/4386610 to your computer and use it in GitHub Desktop.
Save acook/4386610 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
$count = 0
def out *args
# During resizing events, terminals may not do a carriage return
# on their own, so we have to explicitly insert it
print "#{args.join ' '}\r\n"
end
command = lambda { |x|
out "trapped #{$count}"
if $count <= 0 then
$count += 1
out "IM NUMBER #{$count}!!"
resizing = true
while resizing do
sleep 2
print "[#{$count}]"
resizing = false if $count <= 1
end
out "STUFF HAPPENED!!"
else
$count += 1
end
sleep 1
$count -= 1
out "done #{$count}"
}
Signal.trap 'SIGWINCH', command
loop do
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment