aboutsummaryrefslogtreecommitdiff
path: root/2018-linuxdays/examples
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-10-07 20:03:35 +0200
committerKarel Kočí <cynerd@email.cz>2018-10-07 20:03:35 +0200
commit7cf03a1555d46117b5f1a3d0db7c28c02498fcee (patch)
treee7ded2835880ad350fad3209ce667f469858cfed /2018-linuxdays/examples
parent8958b564509b4a4a63004763d70457d3ff5e5392 (diff)
downloadpresentations-7cf03a1555d46117b5f1a3d0db7c28c02498fcee.tar.gz
presentations-7cf03a1555d46117b5f1a3d0db7c28c02498fcee.tar.bz2
presentations-7cf03a1555d46117b5f1a3d0db7c28c02498fcee.zip
Add presentation from LinuxDays 2018
Diffstat (limited to '2018-linuxdays/examples')
-rw-r--r--2018-linuxdays/examples/.bashrc1
-rw-r--r--2018-linuxdays/examples/.zshrc1
-rw-r--r--2018-linuxdays/examples/bash/function4
-rw-r--r--2018-linuxdays/examples/bash/mupdf-pdf1
-rw-r--r--2018-linuxdays/examples/bash/real23
-rw-r--r--2018-linuxdays/examples/bash/simple1
-rw-r--r--2018-linuxdays/examples/bash/switch16
-rw-r--r--2018-linuxdays/examples/gitbmerge/_gitbmerge23
-rw-r--r--2018-linuxdays/examples/gitbmerge/gitbmerge20
-rw-r--r--2018-linuxdays/examples/zsh/dev4
-rw-r--r--2018-linuxdays/examples/zsh/path4
-rw-r--r--2018-linuxdays/examples/zsh/real38
-rw-r--r--2018-linuxdays/examples/zsh/simple4
-rw-r--r--2018-linuxdays/examples/zsh/switch15
14 files changed, 155 insertions, 0 deletions
diff --git a/2018-linuxdays/examples/.bashrc b/2018-linuxdays/examples/.bashrc
new file mode 100644
index 0000000..79ff768
--- /dev/null
+++ b/2018-linuxdays/examples/.bashrc
@@ -0,0 +1 @@
+PS1="\[\e[1;32m\]bash\$\[\e[0m\] "
diff --git a/2018-linuxdays/examples/.zshrc b/2018-linuxdays/examples/.zshrc
new file mode 100644
index 0000000..c006157
--- /dev/null
+++ b/2018-linuxdays/examples/.zshrc
@@ -0,0 +1 @@
+PROMPT="%{$fg_bold[green]%}zsh%(!.#.$)%{$reset_color%} "
diff --git a/2018-linuxdays/examples/bash/function b/2018-linuxdays/examples/bash/function
new file mode 100644
index 0000000..ab6e5da
--- /dev/null
+++ b/2018-linuxdays/examples/bash/function
@@ -0,0 +1,4 @@
+_sterm() {
+ COMPREPLY+=($(compgen -W "9600 19200 38400 57600 115200" -- "${COMP_WORDS[COMP_CWORD]}"))
+}
+complete -F _sterm sterm
diff --git a/2018-linuxdays/examples/bash/mupdf-pdf b/2018-linuxdays/examples/bash/mupdf-pdf
new file mode 100644
index 0000000..3f5c250
--- /dev/null
+++ b/2018-linuxdays/examples/bash/mupdf-pdf
@@ -0,0 +1 @@
+complete -G \*.pdf mupdf
diff --git a/2018-linuxdays/examples/bash/real b/2018-linuxdays/examples/bash/real
new file mode 100644
index 0000000..2dd3f36
--- /dev/null
+++ b/2018-linuxdays/examples/bash/real
@@ -0,0 +1,23 @@
+# Bash completion file for sterm
+# vim: ft=sh
+
+_sterm() {
+ local cur prev words cword
+ _init_completion || return
+ local ops="-h --help -c -d -e -n -r -s -v"
+ case "$prev" in
+ -b|-d|-r)
+ # No completion for these
+ ;;
+ -s)
+ local speeds="0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 9600 19200 38400 57600 115200 230400"
+ COMPREPLY+=($(compgen -W "${speeds}" -- ${cur}))
+ ;;
+ *)
+ COMPREPLY+=($(compgen -W "${ops}" -- ${cur}))
+ COMPREPLY+=($(compgen -G "/dev/tty*" -- ${cur}))
+ ;;
+ esac
+}
+
+complete -o default -F _sterm sterm
diff --git a/2018-linuxdays/examples/bash/simple b/2018-linuxdays/examples/bash/simple
new file mode 100644
index 0000000..76b8813
--- /dev/null
+++ b/2018-linuxdays/examples/bash/simple
@@ -0,0 +1 @@
+complete -W "9600 19200 38400 57600 115200" sterm
diff --git a/2018-linuxdays/examples/bash/switch b/2018-linuxdays/examples/bash/switch
new file mode 100644
index 0000000..db55dd7
--- /dev/null
+++ b/2018-linuxdays/examples/bash/switch
@@ -0,0 +1,16 @@
+_sterm() {
+ local cur prev words cword
+ _init_completion || return
+ case "$prev" in
+ -b|-d|-r)
+ # No completion for these
+ ;;
+ -s)
+ COMPREPLY=($(compgen -W "9600 19200 38400 57600 115200" -- ${cur}))
+ ;;
+ *)
+ COMPREPLY=($(compgen -W "-s -b -d -r" -- ${cur}))
+ ;;
+ esac
+}
+complete -o default -F _sterm sterm
diff --git a/2018-linuxdays/examples/gitbmerge/_gitbmerge b/2018-linuxdays/examples/gitbmerge/_gitbmerge
new file mode 100644
index 0000000..49977dc
--- /dev/null
+++ b/2018-linuxdays/examples/gitbmerge/_gitbmerge
@@ -0,0 +1,23 @@
+#compdef gitbmerge
+#autoload
+
+_gitbmerge() {
+ ((CURRENT > 2)) && return # Complete only single dependency
+ local GDIR="$(pwd)"
+ while [ ! -d "$GDIR/.git" ]; do
+ [ -z "$GDIR" ] && return
+ GDIR="${GDIR%/*}"
+ done
+ GDIR="$GDIR/.git"
+ [ -f "$GDIR" ] && GDIR="$(cat "$GDIR")" # This just points to some other directory
+ [ -d "$GDIR/refs/heads" ] || return # No completion if there is no local branch
+ local branches=()
+ for B in "$GDIR"/refs/heads/*; do
+ # TODO skip branch on HEAD
+ branches+=("${B#$GDIR/refs/heads/}")
+ done
+ _describe -t branches 'gitbmerge' branches
+}
+
+_gitbmerge
+# vim: ft=zsh
diff --git a/2018-linuxdays/examples/gitbmerge/gitbmerge b/2018-linuxdays/examples/gitbmerge/gitbmerge
new file mode 100644
index 0000000..bd892b6
--- /dev/null
+++ b/2018-linuxdays/examples/gitbmerge/gitbmerge
@@ -0,0 +1,20 @@
+_gitbmerge() {
+ [ $COMP_CWORD -gt 1 ] && return # Complete only single dependency
+ local cur prev words cword
+ _init_completion || return
+ local GDIR="$(pwd)"
+ while [ ! -d "$GDIR/.git" ]; do
+ [ -z "$GDIR" ] && return
+ GDIR="${GDIR%/*}"
+ done
+ GDIR="$GDIR/.git"
+ [ -f "$GDIR" ] && GDIR="$(cat "$GDIR")" # This just points to some other directory
+ [ -d "$GDIR/refs/heads" ] || return # No completion if there is no local branch
+ local ops=""
+ for B in "$GDIR"/refs/heads/*; do
+ # TODO skip branch on HEAD
+ ops="$ops ${B#$GDIR/refs/heads/}"
+ done
+ COMPREPLY=($(compgen -W "${ops}" -- ${cur}))
+}
+complete -F _gitbmerge gitbmerge
diff --git a/2018-linuxdays/examples/zsh/dev b/2018-linuxdays/examples/zsh/dev
new file mode 100644
index 0000000..25de542
--- /dev/null
+++ b/2018-linuxdays/examples/zsh/dev
@@ -0,0 +1,4 @@
+_sterm() {
+ _values "tty" /dev/tty*
+}
+compdef _sterm sterm
diff --git a/2018-linuxdays/examples/zsh/path b/2018-linuxdays/examples/zsh/path
new file mode 100644
index 0000000..617d47e
--- /dev/null
+++ b/2018-linuxdays/examples/zsh/path
@@ -0,0 +1,4 @@
+_sterm() {
+ _files
+}
+compdef _sterm sterm
diff --git a/2018-linuxdays/examples/zsh/real b/2018-linuxdays/examples/zsh/real
new file mode 100644
index 0000000..7b2dce6
--- /dev/null
+++ b/2018-linuxdays/examples/zsh/real
@@ -0,0 +1,38 @@
+# vim: ft=zsh
+_sterm_baudrate() {
+ _values "Baudrate" \
+ "0" \
+ "50" \
+ "75" \
+ "110" \
+ "134" \
+ "150" \
+ "200" \
+ "300" \
+ "600" \
+ "1200" \
+ "1800" \
+ "2400" \
+ "4800" \
+ "9600" \
+ "19200" \
+ "38400" \
+ "57600" \
+ "115200" \
+ "230400"
+}
+_sterm() {
+ _arguments \
+ "--help[Output help message]" \
+ "-h[Print help text]" \
+ "-s[Set baudrate]:baudrate:_sterm_baudrate" \
+ "-b[Send break]:break:->ignore" \
+ "-c[Enter command mode]" \
+ "-d[Make pulse on DTR]:pulse:->ignore" \
+ "-r[Make pulse on RTS]:pulse:->ignore" \
+ "-e[Ignore '~.' escape sequence]" \
+ "-n[Do not switch the device to raw mode]" \
+ "-v[Verbose mode]"
+ [ "$state" = "ignore" ] || _values "tty" /dev/tty*
+}
+compdef _sterm sterm
diff --git a/2018-linuxdays/examples/zsh/simple b/2018-linuxdays/examples/zsh/simple
new file mode 100644
index 0000000..b269db3
--- /dev/null
+++ b/2018-linuxdays/examples/zsh/simple
@@ -0,0 +1,4 @@
+_sterm() {
+ _values "Baudrate" "9600" "19200" "115200"
+}
+compdef _sterm sterm
diff --git a/2018-linuxdays/examples/zsh/switch b/2018-linuxdays/examples/zsh/switch
new file mode 100644
index 0000000..09c9b29
--- /dev/null
+++ b/2018-linuxdays/examples/zsh/switch
@@ -0,0 +1,15 @@
+_sterm_baudrate() {
+ _values "Baudrate" "9600" "19200" "115200"
+}
+_sterm() {
+ _arguments \
+ "-s[Set baudrate]:baudrate:_sterm_baudrate" \
+ "-b[Send break]" \
+ "-c[Enter command mode]" \
+ "-d[Make pulse on DTR]" \
+ "-r[Make pulse on RTS]" \
+ "-e[Ignore '~.' escape sequence]" \
+ "-n[Do not switch the device to raw mode]" \
+ "-v[Verbose mode]"
+}
+compdef _sterm sterm