Add RAID viewer.
[libguestfs-talks.git] / 2015-virt-tools / 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 EDITOR="emacs -nw"
12
13 # Ditch libvirt for stability :-(
14 export LIBGUESTFS_BACKEND=direct
15
16 # remember <command> <args ...>
17 #
18 # This function does two things: (1) It adds the command and arguments
19 # to the shell history, so that commands can be recalled using up
20 # arrow or reverse search.  (2) It makes a function key recall the
21 # command.  The first command is assigned to F2, the second to F3 and
22 # so forth.
23
24 rm -f $HISTFILE
25 touch $HISTFILE
26 rm -f $talkdir/bindings
27 touch bindings
28
29 fnum=2
30 keys=(- OP OQ OR OS '[15~' '[17~' '[18~' '[19~' '[20~' '[21~')
31
32 remember ()
33 {
34     echo "$@" >> $HISTFILE
35     echo \"\\e${keys[$fnum]}\":\"\\C-k \\C-u"$@"\" >> $talkdir/bindings
36     ((fnum++))
37 }
38
39 terminal ()
40 {
41     chmod -w $HISTFILE
42     /bin/bash --rcfile $talkdir/bashrc "$@"
43 }