about summary refs log tree commit diff
path: root/Completion/Unix/Type/_sys_calls
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Type/_sys_calls')
-rw-r--r--Completion/Unix/Type/_sys_calls20
1 files changed, 20 insertions, 0 deletions
diff --git a/Completion/Unix/Type/_sys_calls b/Completion/Unix/Type/_sys_calls
new file mode 100644
index 000000000..bd9b34f70
--- /dev/null
+++ b/Completion/Unix/Type/_sys_calls
@@ -0,0 +1,20 @@
+#autoload
+
+# Options:
+#
+# -a    add "all" as an additional match
+# -n    add "none" as an additional match
+
+local expl all none
+local ifile=/usr/include/sys/syscall.h
+local -au syscalls
+
+zparseopts -D -K -E a=all n=none
+
+[[ $OSTYPE = linux* ]] && ifile=/usr/include/bits/syscall.h
+syscalls=( ${${${(M)${(f)"$(<$ifile)"}:#?define[[:blank:]]##SYS_*}#*[[:blank:]]SYS_}%%[[:blank:]]*} ) 2>/dev/null
+[[ -n $all ]] && syscalls+=( all )
+[[ -n $none ]] && syscalls+=( none )
+
+_description syscalls expl 'system call'
+compadd "$@" "$expl[@]" -a syscalls