Skip to content

Instantly share code, notes, and snippets.

@ttdoda
Last active April 26, 2017 01:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttdoda/300e4570c0300197cf69 to your computer and use it in GitHub Desktop.
Save ttdoda/300e4570c0300197cf69 to your computer and use it in GitHub Desktop.
端末のウィンドウが勝手にびよんびよんなってたのしいやつ
#!/usr/bin/env ruby
# License: CC0
include Math
STDOUT.sync = 1
case `env LC_ALL=C stty -a`
when / (\d+) rows; (\d+) columns/
rows = $1.to_i
cols = $2.to_i
when /rows (?:= )?(\d+); columns (?:= )?(\d+)/
rows = $1.to_i
cols = $2.to_i
else
STDERR.puts "Can't get stty result"
exit 1
end
def resize_term(rows, cols)
print "\e[8;#{rows};#{cols}t"
end
i = 0
s = 10
trap(:INT) {
resize_term(rows, cols)
exit 0
}
while true
r = rows + (cos(PI*(i*s)/180) * 10).to_i
c = cols + (sin(PI*(i*s)/180) * 10).to_i
resize_term(r, c)
i += 1
sleep 0.05
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment