summary refs log tree commit diff
path: root/.vim/snippets/sh.lua
diff options
context:
space:
mode:
Diffstat (limited to '.vim/snippets/sh.lua')
-rw-r--r--.vim/snippets/sh.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/.vim/snippets/sh.lua b/.vim/snippets/sh.lua
new file mode 100644
index 0000000..e8ba23b
--- /dev/null
+++ b/.vim/snippets/sh.lua
@@ -0,0 +1,39 @@
+---@diagnostic disable: undefined-global
+return {
+  s(
+    { trig = 'getopts', desc = 'getopts skeleton' },
+    fmt(
+      [=[
+      while getopts h{} opt; do
+      	case ${{opt}} in
+      	h | ?)
+      		printf "usage: %s [-h]\n" "$(basename "$0")"
+      		printf "\n"
+      		exit 2
+      		;;
+      	esac
+      done
+      shift $((OPTIND - 1))
+    ]=],
+      { i(1) }
+    )
+  ),
+
+  s(
+    { trig = 'usage' },
+    fmt(
+      [=[
+      usage() {{
+      	printf "usage: %s{}" "$(basename "$0")\n"
+      	printf "\n"
+      	{}
+      	printf "\n"
+      }}
+    ]=],
+      {
+        i(1, ' []'),
+        i(2, 'printf "  -{}\n"'),
+      }
+    )
+  ),
+}