Skip to content

Commit

Permalink
Update simple example.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwmjones committed Mar 20, 2010
1 parent 1c78e39 commit c80647f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions examples/simple/.gitignore
@@ -0,0 +1 @@
history
6 changes: 3 additions & 3 deletions examples/simple/20-shell.sh
@@ -1,5 +1,5 @@
#!/bin/bash -
source functions
add_history guestfish -a vm1.img
add_history guestfish -a vm2.img -m /dev/sda1
terminal --title="Guestfish demonstration"
add_history echo History command number 2
add_history echo '"History command number 1"'
terminal --title="Press the UP ARROW to get history"
12 changes: 11 additions & 1 deletion examples/simple/30-goodbye.html
Expand Up @@ -6,11 +6,21 @@
</p>

<p>
Now look at these files to find out how we did it:
We hope you noticed on the previous slide that you
could hit the <b>Up arrow</b> to get pre-populated
history.
</p>

<p>
Now look at these files in the current directory
to find out how we did it:
</p>

<ul>
<li> 10-hello.html
<li> 20-shell.sh
<li> 30-goodbye.html
<li> functions &mdash; common shell functions
<li> style.css &mdash; stylesheet
<li> code.js &mdash; Javascript
</ul>
15 changes: 10 additions & 5 deletions examples/simple/functions
@@ -1,14 +1,14 @@
# -*- shell-script -*-

# Need a short sleep to allow the previous shell to exit, possibly
# writing to the history file, before we start the new shell. Could
# write to a different history file each time which would avoid this.
sleep 1
# Place any local environment variables required in 'local'.
if [ -f local ]; then source local; fi

export PS1="$ "
export HISTFILE=/tmp/history

export HISTFILE=$talkdir/history

rm -f $HISTFILE
touch $HISTFILE

add_history ()
{
Expand All @@ -17,6 +17,11 @@ add_history ()

terminal ()
{
# Make $HISTFILE unwritable so the shell won't update it
# when it exits.
chmod -w $HISTFILE

# Run gnome-terminal.
exec \
gnome-terminal \
--window \
Expand Down

0 comments on commit c80647f

Please sign in to comment.