more polish to 5000* demo
[eblake-techtalks.git] / functions
blob4dd50ca9d23217c1d8238d91f307311d477e473a
1 # -*- shell-script -*-
2 # This creates some standard functions.  See also $talkdir/bashrc
3 # which runs in the same bash context as the terminal.
5 # Place any local environment variables and settings in "local".
6 if [ -f local ]; then source local; fi
8 # Environment variables.
9 export HISTFILE=$talkdir/history
10 export PATH=$talkdir:$PATH
11 export EDITOR="emacs -nw"
13 # remember <command> <args ...>
15 # This function does two things: (1) It adds the command and arguments
16 # to the shell history, so that commands can be recalled using up
17 # arrow or reverse search.  (2) It makes a function key recall the
18 # command.  The first command is assigned to F2, the second to F3 and
19 # so forth.
21 rm -f $HISTFILE
22 touch $HISTFILE
23 rm -f $talkdir/bindings
24 touch bindings
26 fnum=2
27 keys=(- OP OQ OR OS '[15~' '[17~' '[18~' '[19~' '[20~' '[21~')
29 remember ()
31     echo "$@" >> $HISTFILE
32     echo "$@" | sed -e 's/\\/\\\\/g; s/"/\\"/g; s/$/"/' \
33         -e 's/^/"\\e'"${keys[$fnum]}"'":"\\C-k \\C-u/' >> $talkdir/bindings
34     ((fnum++))
37 terminal ()
39     clear
40     chmod -w $HISTFILE
41     /bin/bash --rcfile $talkdir/bashrc "$@"
44 banner ()
46     printf "%s   %s   %s\\n" $'\e[1;37;41m' "$1" $'\e[0m'