# Replay previous console text [closed]

Create a script that, when run from a console, will display the text already in the console, prior to running.

# Challenge

• How will the winner of the challenge will be determined?

The golf with the shortest length (in bytes) will win.

# Example Input and Output

Input: (Shown is Windows)

Microsoft Windows [Version 10.0.14393]

C:\Users\CSS>dir
Volume in drive C has no label.
Volume Serial Number is B0A1-E768

Directory of C:\Users\CSS

11/30/2016  07:18 PM    <DIR>          .
11/30/2016  07:18 PM    <DIR>          ..
12/01/2016  04:45 PM    <DIR>          .android
10/25/2016  12:41 PM    <DIR>          .atom
11/29/2016  05:52 PM    <DIR>          .dnx
10/27/2016  09:34 PM               148 .gitconfig
11/28/2016  03:02 PM    <DIR>          .MemuHyperv
11/29/2016  05:55 PM    <DIR>          .nuget
12/01/2016  04:42 PM    <DIR>          .oracle_jre_usage
10/26/2016  11:37 PM    <DIR>          .ssh
12/04/2016  06:20 PM    <DIR>          .VirtualBox
11/29/2016  12:56 PM    <DIR>          .vscode
11/28/2016  03:53 PM             8,528 2016-11-28-20-44-28.000-VBoxSVC.exe-2608.log
11/28/2016  05:09 PM    <DIR>          Andy
11/23/2016  10:01 AM    <DIR>          Contacts
12/11/2016  11:16 PM    <DIR>          Desktop
11/30/2016  07:35 PM    <DIR>          Documents
11/23/2016  10:01 AM    <DIR>          Favorites
11/22/2016  07:23 PM               409 fciv.err
11/22/2016  07:21 PM               266 hi
11/22/2016  04:28 PM                15 me.txt
11/28/2016  03:08 PM    <DIR>          Music
10/25/2016  12:44 AM    <DIR>          OneDrive
12/09/2016  05:57 PM    <DIR>          Pictures
11/23/2016  10:01 AM    <DIR>          Saved Games
11/24/2016  08:56 PM               151 search.bat
11/23/2016  10:01 AM    <DIR>          Searches
11/07/2016  11:00 AM                11 t.bat
11/24/2016  08:55 PM                93 update.bat
11/28/2016  03:08 PM    <DIR>          Videos
8 File(s)          9,621 bytes
24 Dir(s)  152,887,300,096 bytes free

C:\Users\CSS>


Output:

The script must display something like the text above, in the sense that it must display exactly what was in the console before the script was called.

• Must it print out the entire terminal history, or just what's in the current window? – Gabriel Benamy Dec 12 '16 at 18:35
• @GabrielBenamy The entire terminal history. – cascading-style Dec 12 '16 at 18:45
• What precisely does "before the script was called" mean? When is the script called? If the invocation is directly from the terminal, is it when the user starts typing in the path to the script, or when they hit enter? If the invocation is indirect via a script which invokes my script, is it when the wrapper script is called or when it invokes my script? – Peter Taylor Dec 12 '16 at 19:04
• @PeterTaylor The script is called when you hit enter. The script does not need to filter out the characters from the script being invoked. However, bonus points if it does. – cascading-style Dec 12 '16 at 19:08
• The entire history of what was typed into the terminal is not necessarily stored anywhere. – feersum Dec 12 '16 at 19:16

osascript -e 'tell app "System Events" to keystroke "ac" using command down'