Bash command line help scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

874 B

shtpl

sh templating

Install

Put the shtpl script somewhere meant for executable scripts like ~/bin/shtpl. Make it executable: chmod +x shtpl.

Usage

Create a template file to be executed with shtpl:

nano someTpl.shtpl
#!/path/to/shtpl
Hello $WHO !
chmod +x someTpl.shtpl
WHO=Doctor someTpl.shtpl
> Hello Doctor !

Templating syntax

shtpl uses a hack to turn you file into a call of echo "<your file here>", so it is simple, all what your system is able to understand as substitution is valid !

#!/path/to/shtpl
Simple variable: $ENV_VAR , and with brackets: ${TOTO}cm²

Sub commands: $(echo ok)

Prompt user input in place: $(read -r -p Type\ some\ text\ : v;echo $v)

Loops: $(
for ((i=0 ; $MAX_LOOP - $i ; i++))
    do
	echo $i
done
)

Call sub templates: $(VAR_TO_PASS=$SOME_VAR ./myOtherTemplate.shtpl)