Files
q-tools/reporting/markslider
2014-04-16 19:25:15 +03:00

246 lines
6.4 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
VERSION=20140416
function display_self {
$0 $0
exit 0
}
[ -z "$1" ] && display_self
[ "$1" = "-h" ] && display_self
[ -f "$1" ] || {
echo Cannot find file: $1
exit 1
}
function display_slide {
j=$(( $2 + 1 ))
echo -en "$CLS"
awk 'match($0,/^# /){
c++;
print c $0;
}
!/^# /{
print $0;
}
' "$1" | sed -n '/^'$2'# /,/^'$j'# /p' | grep -v "^$j# " | sed 's,^'$i'\(# .*\),'$H'\1'$Z',' | eval sed $REGEX
}
function slide_exec {
# find executables in the slide
j=$(( $2 + 1 ))
echo -en "$CLS"
while read line
do eval $line > /dev/null 2>&1 &
done < <(
awk 'match($0,/^# /){
c++;
print c $0;
}
!/^# /{
print $0;
}
' "$1" | sed -n '/^'$2'# /,/^'$j'# /p' | grep "^\$( " | sed -e 's,^\$( ,,' -e 's,)$,,' )
}
E='\x1b['
H="${E}1m"
Z="${E}0m"
CLS="${E}2J${E}H"
#list of text colors:
BLACK="${E}30m"
R="${E}31m"
G="${E}32m"
B="${E}34m"
Y="${E}33m"
M="${E}35m"
C="${E}36m"
W="${E}37m"
#list of BG colors:
BGR="${E}41m"
BGG="${E}42m"
BGB="${E}44m"
BGY="${E}43m"
BGM="${E}45m"
BGC="${E}46m"
BGW="${E}47m"
CONF_LINE=( \${H} \${Z} \${R} \${G} \${B} \${Y} \${M} \${C} \${W}
\${BLACK} \${BGR} \${BGG} \${BGB} \${BGY} \${BGM} \${BGC} \${BGW} )
for (( r=0; r<${#CONF_LINE[@]}; r++ ));
do value=CONF_LINE[$r]
replace=$( eval echo ${!value} )
REGEX="$REGEX -e 's/\(${CONF_LINE[$r]}\)/"${replace}"/g'"
done
REGEX="$REGEX -e 's/^\$([^\$]\+)/\$(*)/g'"
#echo $REGEX
#exit
i=1
MENU=1
while true
do
# print slide $i
NO_SLIDES=$( grep -ce "^# " "$1" )
COLS=$(( $( tput cols ) - 3 ))
display_slide "$1" $i
# ask for user input
# 1 back, 2 forward, q exit, m menu
echo -ne "${Z}${E}1;${COLS}H"
[ -z "$MENU" ] || {
echo -ne "${i}/${NO_SLIDES}"
echo -ne "${E}1B${E}3D1:▶"
echo -ne "${E}1B${E}3D2:◀"
echo -ne "${E}1B${E}3Dq:x"
echo -ne "${E}1B${E}3Dm:▲${E}4A"
}
read -s -N 1 cmd
# Escape inputed if arrow keys used
[ "$cmd" = "" ] && read -s -N 2 cmd
case "$cmd" in
2|"[D")
i=$(( $i - 1 ))
[ $i -lt 1 ] && i=1
;;
1|"[C"|"")
i=$(( $i + 1 ))
[ $i -gt $NO_SLIDES ] && i=$NO_SLIDES
;;
m)
[ -z "$MENU" ] && {
MENU=1
} || {
unset MENU
}
;;
x|q)
echo -ne "${E}1E"
exit
;;
e)
slide_exec "$1" $i
;;
esac
done
done
exit
"
# Markdown Slide Presenter: MarkSlider
* This tool prints a text file as slides,
retaining the formatting. Consider
using markdown syntax.
* Syntax ref: http://daringfireball.net/projects/markdown/syntax
* The only parsed syntax is the new slide syntax:
A row starting with '# '
## How to use ##
* Give the markdown file as argument
* Move to the next slide with key 1
* Move to the previous slide with key 2
* Exit with q or x
* Hide menu with m
* The numbers on the right show the current
and number of slides in this presentation
# Hints: Tables
* Create tables with "ncsv -m"
Object Area Perimeter
------- ----- ----------
1 358 68.28
2 444 77.36
3 507 92.18
4 1026 118.6
5 539 84.18
# Hints: Plots
* Create plots with gnuplot:
set term dumb 60 15 enhanced
set parametric; set trange [0:10*pi]; set yrange[-5*pi:5*pi]
set xrange[-10*pi:10*pi]; plot t*cos(t), t*sin(t)
15 ++-----*-+---**--+--------+-------+**-----*-------++
|+ ** + ** + *****t*cos(t), t*sin(t)*******+|
| * ** *** *** ** * |
10 ++ * ** *** ** ** * ++
| ** * ** ******** ** * * |
5 ++ * ** * *** ** * ** ** ++
| * * * ** ** ** * * |
0 ++ * * * * **** * * * * ++
| * * * * * ** ** * * *
| * * * * ** *** * ** ** *
-5 ++ * * * ** ***** ** * * **
| * ** * ** *** ** * *|
-10 ++ ** * ** *** **** ** * *+
| * ** ** ****** ** ** * |
|+ * + * *** + *** ** * +|
-15 ++----*--+--*----+-**-----+-----**+------*+----*--++
-30 -20 -10 0 10 20 30
# Hints: ${R}Co${Y}lo${G}rs
* Use ANSI codes directly for colors, or shortcuts:
${R}red: ${ R}, ${G}green: ${ G}, ${B}blue: ${ B}${Z}
Colors: R G B C M Y W BLACK
${H}Bright modifier: ${ H}, ex: ${H}${Y}yellow ${ H}${ Y}${Z}
Background colors:${H}${C}${BGM} bright cyan on magenta ${ H}${ C}${ BGM} ${Z}
Background colors: BGR BGG BGB BGC BGM BGY BGW
Reset colors with ${ Z}
# Hints: Presenting
* Use a terminal with large font, perhaps 80 columns on screen
* Fullscreen often with F11
┌──────┐
* Get creative with │Ascii!│
└┬────┬┘
* Run any command with pressing "e" on a slide with
syntax beginning a row: "$ ( command )"
$( xeyes )
# Hints: Other tools
* Check out tools like:
* toilet
m " ""# m
mm#mm mmm mmm # mmm mm#mm
# #" "# # # #" # #
# # # # # #"""" #
"mm "#m#" mm#mm "mm "#mm" "mm
* boxes
_ ._ _ , _ ._
(_ ' ( ` )_ .__)
( ( ( ) `) ) _)
(__ (_ (_ . _) _) ,__)
`~~`\ ' . /`~~`
,::: ; ; :::,
':::::::::::::::'
_jgs______/_ __ \__________
| |
| MarkSlider |
|___________________________|
# Hints: More tools
* JPEG to ascii: jp2a
MMMMMNNNNNMNkkk0MMWdll0MMMMMOc,,;cllc;,,
MMMMNNNNNMNOkOXMMKolkNMMW0ocdOXWMMMMMMWX
MMMNNNNNMNOkONMMkldNMMWx:dXMMMMWKOxxxOKW
MMWNNNNMWOkkNMMxlxWMMK;oWMMMXoloOXNWNXOd
MMNNNNWM0kkKMMOldMMM0,OMMMNclNMMMMM:WMMM
MWNNNNMNkkOWMNllNMMN,xMMMN'KMMMMMMM NMMM
MWNNNNMXkk0MM0ldMMMx,WMMM;kMMMMMMMW XMMM
MWNNNWMKkk0MMOlxMMMl:MMMM.NMMMMMMMO.xMMM
MWNNNNMXkk0MM0ldMMMx,WMMM;kMMMMMMN.; KMM
MWNNNNMNkkOWMNllNMMN,xMMMN'KMMMMK..,. 0M
MMNNNNWM0kkKMMOldMMM0,OMMMNclNMN:;NMW:;K
MMWNNNNMWOkkNMMxlxWMMK;oWMMMXoloOXNWNXOd
MMMNNNNNMNOkONMMkldNMMWx:dXMMMMWKOxxxOKW
MMMMNNNNNMNOkOXMMKolkNMMW0ocdOXWMMMMMMWX
MMMMMNNNNNMNkkkKMMWdll0MMMMMOc,,;cllc;,,