diff options
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Builtins/_print | 11 | ||||
-rw-r--r-- | Completion/Core/.distfiles | 4 | ||||
-rw-r--r-- | Completion/Core/_file_descriptors | 23 |
3 files changed, 32 insertions, 6 deletions
diff --git a/Completion/Builtins/_print b/Completion/Builtins/_print index f2634e124..11b089a14 100644 --- a/Completion/Builtins/_print +++ b/Completion/Builtins/_print @@ -1,10 +1,14 @@ #compdef print -local state expl line eflag +local state expl line eflag pflag # -e flag available only after -R eflag="${words[1,CURRENT-1][(r)-*R*]:+-e[enable escapes]}" +# -p flag only relevant if we have a coprocess +(:>&p) 2>/dev/null && + pflag='(-s -u -z)-p[print arguments to input of coprocess]' + _arguments -C -s \ '-r[ignore escape conventions of echo]' \ '(-r -b -m -s -l -N -o -O -i -c -u -p -z -D -P)-R[emulate BSD echo (no escapes, -n & -e flags only)]' \ @@ -18,9 +22,8 @@ _arguments -C -s \ '(-o)-O[sort arguments in descending order]' \ '-i[case-insensitive sorting]' \ '(-n -l -N)-c[print arguments in columns]' \ - '(-s -p -z)-u+[specify file-descriptor to print arguments to]:file-descritor' \ - '(-s -u -z)-p[print arguments to input of coprocess]' \ + '(-s -p -z)-u+[specify file-descriptor to print arguments to]:file-descriptor:_file_descriptors' \ '(-s -p -u)-z[push arguments onto editing buffer stack]' \ '-D[substitute any arguments which are named directories using ~ notation]' \ '-P[perform prompt expansion]' \ - $eflag '*:default:_default' + $pflag $eflag '*:default:_default' diff --git a/Completion/Core/.distfiles b/Completion/Core/.distfiles index ff67b283e..9ddf7f523 100644 --- a/Completion/Core/.distfiles +++ b/Completion/Core/.distfiles @@ -1,8 +1,8 @@ DISTFILES_SRC=' .distfiles _all_labels _alternative _approximate - _call _compalso _complete _correct _description - _expand _files _funcall _ignored _list _main_complete _match + _call _compalso _complete _correct _description _expand + _file_descriptors _files _funcall _ignored _list _main_complete _match _menu _multi_parts _message _next_label _normal _oldlist _options _parameters _path_files _prefix _requested _sep_parts _set_options _setup _sort_tags _tags diff --git a/Completion/Core/_file_descriptors b/Completion/Core/_file_descriptors new file mode 100644 index 000000000..37e44c068 --- /dev/null +++ b/Completion/Core/_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 - "$fds[@]" +else + _wanted file-descriptors expl 'file descriptors' compadd "$@" - "$fds[@]" +fi |