-
-
Notifications
You must be signed in to change notification settings - Fork 198
Expand file tree
/
Copy pathparrot-dance.ps1
More file actions
31 lines (27 loc) · 817 Bytes
/
parrot-dance.ps1
File metadata and controls
31 lines (27 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<#
.SYNOPSIS
Makes a parrot dance on your shell.
.EXAMPLE
./parrot-dance.ps1
#>
$request = [System.Net.HttpWebRequest]::Create("http://parrot.live");
$response = $request.GetResponse();
$receiveStream = $response.GetResponseStream();
$readStream = [System.IO.StreamReader]::new($receiveStream);
[console]::TreatControlCAsInput = $true;
$initialForegroundColor = [Console]::ForegroundColor;
while ($line = $readStream.ReadLine()) {
if ([Console]::KeyAvailable) {
$key = [System.Console]::ReadKey($true)
if (($key.modifiers -band [ConsoleModifiers]"control") -and ($key.key -eq "C"))
{
break;
}
}
[Console]::WriteLine($line);
}
$readStream.Close();
$receiveStream.Close();
$request.Abort();
[console]::TreatControlCAsInput = $false;
[Console]::ForegroundColor = $initialForegroundColor;