about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:19:30 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:19:30 +0000
commitbf5ca4e6e161fef3f314a780bb01bfab368a46fe (patch)
treed931326eeb85f95a295ba634f88c0eca39a5e2a3 /Completion
parent888ff2fc2c5830d3fc6216439f321b9410b9d0e7 (diff)
downloadzsh-bf5ca4e6e161fef3f314a780bb01bfab368a46fe.tar.gz
zsh-bf5ca4e6e161fef3f314a780bb01bfab368a46fe.tar.xz
zsh-bf5ca4e6e161fef3f314a780bb01bfab368a46fe.zip
moved from Completion/Core/_file_descriptors
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Zsh/Type/_file_descriptors23
1 files changed, 23 insertions, 0 deletions
diff --git a/Completion/Zsh/Type/_file_descriptors b/Completion/Zsh/Type/_file_descriptors
new file mode 100644
index 000000000..56f6905c6
--- /dev/null
+++ b/Completion/Zsh/Type/_file_descriptors
@@ -0,0 +1,23 @@
+#autoload
+
+local i fds expl list link
+
+for i in {0..9}; [[ -e /dev/fd/$i ]] && fds=( ${fds[@]} $i )
+
+if zstyle -T ":completion:${curcontext}" verbose && [[ -e /proc/$$/fd ]]; then
+  if zmodload -e zsh/stat; then
+    for i in "${fds[@]}"; do
+      stat +link -A link /proc/$$/fd/$i
+      list=( ${list[@]} "$i -- ${link[1]}" )
+    done
+  elif (( $+commands[readlink] )); then
+    for i in "${fds[@]}"; list=( ${list[@]} "$i -- $(readlink /proc/$$/fd/$i)" )
+  else
+    for i in "${fds[@]}"; do
+      list=( ${list[@]} "$i -- $(ls -l /proc/$$/fd/$i|sed 's/.*-> //' )" )
+    done
+  fi
+  _wanted file-descriptors expl 'file descriptors' compadd "$@" -d list -a fds
+else
+  _wanted file-descriptors expl 'file descriptors' compadd "$@" -a fds
+fi