Question 3, the cutting and pasting of shell commands:
Well, personally, I rarely cut and paste shell commands without first
copying them into Emacs and looking at them carefully, so having to
delete the non-command lines and characters isn't a big deal to me.
Probably the simplest solution that's both easy to maintain and read
is to strip out the shell prompt from command lines, and prefix all
command lines with a short unique string. Then in the introduction or
some appendix, provide the user with a simple command (different
flavors, for shell/sed, Emacs, tclsh, etc.) to strip out all lines
which are not either a shell command line, or whitespace.
Alternately, leave the command lines unprefixed and prefix all
non-command lines with some short unique string. I'm not
sure which would be better.