Fake demostration software for command line

3

1

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...

Joe

Posted 2012-12-16T15:38:11.613

Reputation: 2 942

What OS are you on? – slhck – 2012-12-16T15:44:58.833

1Have you tried aliases? It wouldn't look as nice, but you could just type a1, a2, a3, a4, a5... – bb010g – 2012-12-16T15:52:10.410

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 – 2012-12-16T16:11:37.210

@slhck - OSX - will add, although I'm interested in general solutions – Joe – 2012-12-16T16:42:04.247

@bb010g, that's going to be my backup plan I think... :) – Joe – 2012-12-16T16:42:25.090

@Synetech - partly because then it will probably be obvious to the class that I'm just showing them the video - but more fundermentaly I might want to quit the app after a certain stage and show some other aspects of the files that are being produced created - perhaps in response to a question - with a video you'd lose any possibility of the interaction. :( – Joe – 2012-12-16T16:44:12.233

I looked at the question again, and if you are willing to type out the whole thing each time, ZSH has corrections and tab-complete for commands at least. – bb010g – 2012-12-16T16:49:16.550

partly because then it will probably be obvious to the class that I'm just showing them the video   So?     I might want to… possibility of the interaction.   Fair enough. Plus, with a video, you lose the possibility of unexpected things happening and livening up what might otherwise be a dull class. ;-D – Synetech – 2012-12-16T20:11:55.933

there's a program mentioned once on a youtube program called hack5 though i don't recall it offhand. – barlop – 2012-12-16T21:51:04.693

Keeping open because of the very narrow nature of the question. See http://meta.superuser.com/questions/2324/in-defense-of-obscure-niche-hardware-recommendation-questions

– bwDraco – 2014-04-22T12:16:20.267

Answers

1

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.

user49740

Posted 2012-12-16T15:38:11.613

Reputation: 2 850

Excellent - hopefully I'd be back with a version that does the buisness - but you've certainly given me the tools... – Joe – 2012-12-24T21:02:16.647

0

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.

Synetech

Posted 2012-12-16T15:38:11.613

Reputation: 63 242

0

I wrote shellscript-runner.zsh to do what you want. Download it, run zsh, then while in zsh, source the file. Now shellscript-runner is armed and ready for you to run the built-in demo. Read your way through the demo text at the end of the file, and try it out. I hope you'll find it every powerful and easy to use.

Your desire to be able to control when each character appears is not currently implemented but could be added.

Zsh (in case you've never tried it) has many features not present in bash. Zsh's powerful line-editing features, made shellscript-runner possible. It would be impossible to implement in bash.

daveyost

Posted 2012-12-16T15:38:11.613

Reputation: 11