Import old talks from 2010 and 2011 (Boston).
[libguestfs-talks.git] / 2011-boston / talk / functions
1 # -*- shell-script -*-
2 # This creates some standard functions.  See also $talkdir/bashrc
3 # which runs in the same bash context as the terminal.
4
5 # Place any local environment variables and settings in "local".
6 if [ -f local ]; then source local; fi
7
8 # Environment variables.
9 export HISTFILE=$talkdir/history
10 export PATH=$talkdir:$PATH
11 export LIBVIRT_DEFAULT_URI=qemu:///system
12 export EDITOR="emacs -nw"
13
14 # remember <command> <args ...>
15 #
16 # This function does two things: (1) It adds the command and arguments
17 # to the shell history, so that commands can be recalled using up
18 # arrow or reverse search.  (2) It makes a function key recall the
19 # command.  The first command is assigned to F2, the second to F3 and
20 # so forth.
21
22 rm -f $HISTFILE
23 touch $HISTFILE
24 rm -f $talkdir/bindings
25 touch bindings
26
27 fnum=2
28 keys=(- OP OQ OR OS '[15~' '[17~' '[18~' '[19~' '[20~' '[21~')
29
30 remember ()
31 {
32     echo "$@" >> $HISTFILE
33     echo \"\\e${keys[$fnum]}\":\"\\C-k \\C-u"$@"\" >> $talkdir/bindings
34     ((fnum++))
35 }
36
37 # terminal [--title=<title>]
38 #
39 # This command launches the terminal.  Usually used as the last line
40 # of the script.
41 #
42 # Note: If you hand-configure gnome-terminal by adding a new profile
43 # (eg. with larger fonts) then you can use that profile here by
44 # replacing the --window flag with --window-with-profile=ProfileName
45
46 terminal ()
47 {
48     chmod -w $HISTFILE
49     exec \
50         gnome-terminal \
51         --window-with-profile=Large \
52         --geometry=+140+64 \
53         --hide-menubar \
54         --disable-factory \
55         -e "/bin/bash --rcfile $talkdir/bashrc" \
56         "$@"
57 }