Skip to content

Commit 025a26f

Browse files
author
Damien Nadé
committed
tutorial/0-completion: automatic completion demo
1 parent 3447cc3 commit 025a26f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tutorial/0-completion

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
tutorial_directory=${BASH_SOURCE[0]%/*}
4+
5+
# This script creates a custom (volatile) bashrc that will basically
6+
# just enable programmable completion for other tutorial scripts and
7+
# invoke an interactive shell
8+
read -N 4096 bashrc <<EOF
9+
shopt -s progcomp sourcepath
10+
PATH="$PATH:$tutorial_directory"
11+
. "$tutorial_directory/../argsparse-completion.sh"
12+
complete -F _argsparse_complete \
13+
1-basics 2-values 3-cumulative-options \
14+
4-types 5-custom-types 6-properties \
15+
7-value-checking 8-setting-hook 9-misc
16+
17+
cd "$tutorial_directory" || exit
18+
19+
printf "You are currently in %s directory and completion is enabled.\\\\n" \
20+
"$tutorial_directory"
21+
printf "Try:\\\n\\\\n./1-basics -<tab><tab>\\\\n\\\\n"
22+
EOF
23+
exec bash --rcfile <(printf %s "$bashrc") -i

0 commit comments

Comments
 (0)