about summary refs log tree commit diff
path: root/Completion/Unix/Type/_ttys
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Type/_ttys')
-rw-r--r--Completion/Unix/Type/_ttys19
1 files changed, 19 insertions, 0 deletions
diff --git a/Completion/Unix/Type/_ttys b/Completion/Unix/Type/_ttys
new file mode 100644
index 000000000..5e5598570
--- /dev/null
+++ b/Completion/Unix/Type/_ttys
@@ -0,0 +1,19 @@
+#autoload
+
+# Options:
+#
+# -d  strip /dev/ prefix from matches
+# -D  matches allowed with or without /dev/ prefix
+
+local -a ttys expl pre
+local stripdev optdev
+
+zparseopts -D -K -E d=stripdev D=optdev
+
+ttys=( /dev/tty?*(N) /dev/pts/^ptmx(N) )
+ttys=( ${ttys#/dev/} )
+[[ -z $stripdev ]] && pre=( -p /dev/ )
+
+_description ttys expl 'tty'
+[[ -n $optdev ]] && compadd "$@" "$expl[@]" -M 'r:|/=* r:|=*' -a ttys && return
+compadd "$@" "$expl[@]" "$pre[@]" -M 'r:|/=* r:|=*' -a ttys