Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save kristiannissen/a5451fe6006f304e9e75446dbb749ed7 to your computer and use it in GitHub Desktop.

Select an option

Save kristiannissen/a5451fe6006f304e9e75446dbb749ed7 to your computer and use it in GitHub Desktop.
Bash as a template language
// Reference https://devhints.io/bash
// If statements
if [[1+1=2]] then
echo "String is empty"
elif [[1+1=3]] then
echo "String is not empty"
fi
^(if|elif)\s\[\[(.*)\]\]\s(then)$ // With T${1}E1${2}S${3} as replacement matches
TifE11+1=2Sthen
echo "String is empty"
TelifE11+1=3Sthen
echo "String is not empty"
fi
\s(echo)\s"?(.*)"? // With T${1}E${2} as replacement matches
TechoEString is empty
// Also matches
echo $1
^(fi) // With T${1} as replacement matches
TFI
for i in /etc/rc. do
echo $i
done
^(for)\s(.*)\s(do)$ // With T${1}E${2} as replacement matches
TforEi in /etc/rc.
^(done) // With T${1} as replacement matches
Tdone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment