This was first published on https://blog.dbi-services.com/using-tmux-for-semi-interactive-demos (2014-11-06)
Republishing here for new followers. The content is related to the the versions available at the publication date
You are a speaker and like to show some demos. Which kind of demo do you do?
And I don’t like the third one because of:
When I type during a demo http://t.co/cMTLJz1smE pic.twitter.com/HMxFlYy2yc
— DBA Reactions (@DBAReactions) November 2, 2014
And there is something else I want to avoid: I don’t want to sit behind my laptop. I like interactions with attendees during presentations. Especially during demos because this is where the ideas come out.
So today I did something different when presenting dbvisit replicate at SOUG. It was mostly demos: setup, start replication, show conflict resolution, etc.
I stayed stand up, running my demos with my remote presenter. Each click pasting the next command. I’ve sit and typed only to show non-prepared things, answering questions. Even when I need to copy/paste a previous result (the SCN given by the prepare table in order to run a refresh from SCN) the copy paste was scripted: search a pattern in the screen, copy and paste.
People were surprised (which was my second goal of course) and asked me how to explain how I did that. I used tmux and I promised to explain in a blog post.
So here it is. I’ve made a short demo using the same technique.
Tmux is a terminal multiplexer, like screen which you probably use once you have been disconnected at the end of a recovery session. But tmux synchronize multiple windows. That means that I can have two windows for my session. One, with big fonts and full screen, goes to the beamer screen for the demo. And the other one is on my laptop, smaller because I want to see several windows at the same time.
That’s the first point. Instead of ‘duplicate’ my screen with Win-P, I keep the ‘extend’ screen that I have with powerpoint and have a different view from what I show.
The second point is that tmux can show different panes on the same window. Here, to show logical replication, I had one pane on the source, one on the target, and one small with swingbench running.
Here is a picture of that, when I’ve the dbvrep setup wizard on top, and verifying tnsnames.ora in the bottom:
The third point is that you can type into the tmux window either interactively, or from a tmux send-keys command. When I prepare my demos, I run them several times, adjusting what I want to show. So there I’ve just prepared the tmux send-keys lines so that I can run them one by one, or all of them in sequence automatically. Here is the first part of my script which set the windows. I have Cygwin, so I open windows with mintty but you can use whatever you want.
# I kill session if already exists 2>/dev/null tmux kill-session -t demosession 2>/dev/null # Then start a new session not attatched to the current terminal tmux new-session -s demosession -d -n demo bash # I use vi mode keys rather than emacs tmux set-window-option -g mode-keys vi # Then I will open 2 terminals attached to that session: one is full screen with # big fonts, for the beamer, and one is smaller for my laptop to see that I do. # I'm on cygwin and use 'mintty'. Each one attatches to the same session: what you # type on one is seen in both. # the one to show on the beamer is called 'DEMO' mintty -p 700,100 -s 80,60 -o FontHeight=16 -t "DEMO $(date +%d.%m.%Y) - tmux - " tmux attach-session -t demosession & # mine is called 'presenter' mintty -p 800,0 -s 82,45 -o FontHeight=11 -t presenter tmux attach-session -t demosession & sleep 1Then I open the following script with vim where I have a macro that maps the ‘Page Down’ key (which is the one send by my remote presenter for powerpoint next slides) to execute the current line. So i can run each line one after each other, just clicking ‘next slide’ on my remote.
# Now ready to setup the panes I'll use # I want a 10 lines pane at the bottom ( vertical split ) tmux split-window -t demosession:0.0 -v -l 10 bash # And I split that pane (pane number 1 on window 0) to a 10 columns one on the right tmux split-window -t demosession:0.1 -h -l 30 bash # we can check the pane numbers tmux display-panes # now running in pane 1 tmux select-pane -t demosession:0.1 # show the date tmux send-keys "date" # enter 'enter' tmux send-keys C-M # well, there is another way... tmux clock-mode -t .2 # now running in pane 0 tmux select-pane -t demosession:0.0 # now running a few commands in order to show copy/paste tmux send-keys 'sqlplus sys/manager@192.168.78.216/DB1 as sysdba' tmux send-keys C-M tmux send-keys 'create table DEMO (ts timestamp); ' tmux send-keys C-M tmux send-keys 'insert into DEMO select current_timestamp ts from dual; ' tmux send-keys C-M tmux send-keys 'commit; ' tmux send-keys C-M tmux send-keys 'select current_scn from v$database; ' tmux send-keys C-M tmux send-keys 'insert into DEMO select current_timestamp ts from dual; ' tmux send-keys C-M tmux send-keys 'select * from DEMO; ' tmux send-keys C-M tmux send-keys 'select * from DEMO as of scn ' # here I need to copy/paste the SCN. I enter copy mode tmux copy-mode # and search for 'CURRENT_SCN'and down 2 lines ( I'm in vi mode + space to select) tmux send-key ? "CURRENT_SCN" c-M j j " " $ # 'enter' to copy tmux send-key c-M # then paste tmux paste-buffer # finish the statement tmux send-key "; " c-M # clean all tmux send-keys 'drop table DEMO; ' tmux send-keys C-M tmux send-keys '#exit ' tmux send-keys C-M tmux kill-session -t demosessionYou can refer to the tmux manual. I used only a few commands. The copy/paste is the more tricky one, but also the one with the better effect during the presentation.
Here is a screencast of running the above example: http://screencast-o-matic.com/watch/c2X1Y4e2Lt
It’s a short one but shows all the things I’ve used in my demos this morning.
Finally, you probably want to see my .vimrc file that maps the ‘Page Down’ (I don’t use PageDown in vi):
I check (with grep) that my command starts with tmux, and I search for the next tmux command to position the next line to run. This can probably be improved a lot but was sufficient for what I do.
Don’t forget that if anything goes wrong during the demo, you still can sit and have your commands that you can copy/paste in your presenter window. It’s synchronized on the demo window. And nobody can see you cheat sheet. I had an issue this morning because the window was smaller than I thought (beamer resolution) and the dbvrep console didn’t show all my tables. I just resized the pane manually and get back to my copy/paste. So knowing a few tmux interactive commands (type control-b ? for the help) is a good thing.
Finally, you have less stress because automation let you test it more times before. Just run it quickly (PageDown-PageDown-PageDown-…) the day before and you will see if your VM, your database, is still in the expected configuration. And during the preentation, you can go quicker (maybe I made it too fast the morning however) without wondering about typing mistakes, and have more time for interaction with attendees.
Thanks for sharing, really useful.
Hey Franck, I went to see the screencast but it never loaded. 1. Do you have a backup on YouTube? I’m interested in knowing more about demoing technique. 2. Also, how would you handle it if you had to show the browser at some point? —Alberto
Hi, yes, the Screencast O Matic uses Java which doesn’t work on current browers. 1. Here it is https://youtu.be/HI2CCzfSyFw 2. If I have something to show on the browser I put it on beamer screen only, or share my screen. This tmux technique is good only for tty. Regards, Franck.
Hello,
Based on this I made https://github.com/javier-lopez/vlide.vim, thanks for the idea =)!
Hi Javier, This looks very interesting. I’ll definitely try that for no-slides presentations. Thanks, Franck.