Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for some software that would be useful for giving demonstrations.

I regularly have to show the effects of scrips ect to classes while talking about their effects, and equaly regularly I have finger trouble and have to rewrite various commands - wasting class time and general energy.

I'd like to be able to record a sequence of commands in advance, and then play them back at the speed of my choosing.

So I might have a file that containes the commands:

echo "hello world!" 
ls ls -l  
ls -l | sort

I'd like to be able to play these commands back by typing similar ones in.

So I'd have a blinking command prompt and if I typed 'echo "hxxx' the command prompt would read

home$echo "hell

and if I typed any other letters the terminal would fill up with the remainder of the command until I press enter, when it executes the command. The point is that even if I screw up the command when typing it, the command that I'd prepared in advance would be executed.

My question is - does similar software exist for giving demonstrations? or even, is this an easy thing to script up...?

EDIT - two quick things first of all I'm on osx - but it would be nice to get a general solution for other people who arrive here from google. and second a lot of the comments/answers are concentrating on, in effect, making it fast and easy to enter long commands by means of hotkeys and the like. Actually I'd like it to at least look like I'm typing live - that's why I put in the bit about the one-to-one keymapping, but I don't think I explained that quite as well as I could have...

share|improve this question
    
What OS are you on? –  slhck Dec 16 '12 at 15:44
1  
Have you tried aliases? It wouldn't look as nice, but you could just type a1, a2, a3, a4, a5... –  bb010g Dec 16 '12 at 15:52
    
Why not just use screencasting software to record you doing it slowly, carefully in your office, then play the video back in class at the desired speed? For example, VLC lets you adjust playback speed in increments as little as 10%. –  Synetech Dec 16 '12 at 16:11
    
@slhck - OSX - will add, although I'm interested in general solutions –  Joe Dec 16 '12 at 16:42
    
@bb010g, that's going to be my backup plan I think... :) –  Joe Dec 16 '12 at 16:42

3 Answers 3

up vote 1 down vote accepted

You can use Perl and the IO::Prompter module. Here's a script that should help

#!/usr/bin/perl -w

use IO::Prompter<<EOF;
echo "Hello world!"
ls ls -l
ls -l | sort
EOF

use strict;
use feature 'say';
use IPC::Open2;
use Time::HiRes 'sleep';

open2('>&STDOUT',\*SHELL,'bash');

while(my $cmd=prompt '$'){
        say SHELL $cmd;
        sleep 0.05;
}

This script gives you a prompt (configurable, just edit the argument to prompt) and each keystroke inserts a character from the command block above. Backspace works too, and you can also press enter and IO::Prompter will auto-complete the line and send it to bash at a reasonable writing speed. After running the commands from the command block, the script will continue to accept any input and will send it to bash.

You should have Perl already installed. To install IO::Prompter, run cpan IO::Prompter from your favourite terminal emulator.

share|improve this answer
    
Excellent - hopefully I'd be back with a version that does the buisness - but you've certainly given me the tools... –  Joe Dec 24 '12 at 21:02

What about a macro-recorder or IronAHK?

  • With IronAHK (the Linux/Mac port of AutoHotkey), you could assign keystrokes or strings to keys to make it fast and easy to enter whole chunks of data and commands. For example, you could assign the following commands as either raw strings, or as a call to system commands.

    echo "hello world!" 
    ls ls -l  
    ls -l | sort
    

    Then you can bind it to a key like A, or +1, or +Shift+F1 or whatever you like. Then you can press the hotkeys in order at runtime (this is made easier by using numeric hotkeys).

    By organizing the commands down into groups, you can get as fine-grained as you like so that you can break in at any point you think you may want or need to pause the demonstration to do something else like show files, etc.

  • With a macro-program, you can record your keystrokes, then play them back, usually with the ability to adjust the speed-control.

share|improve this answer

I think this zsh code is what you are looking for.

You provide an array of commands. Then for each command in the array, ctrl-down-arrow copies the command to the command line (where you can edit it if you like) then you hit Enter.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.