Last active
December 10, 2015 05:18
-
-
Save acook/4386610 to your computer and use it in GitHub Desktop.
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 | |
$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