From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14749 invoked from network); 4 Jan 1997 11:25:36 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 4 Jan 1997 11:25:36 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id GAA04430; Sat, 4 Jan 1997 06:31:00 -0500 (EST) Resent-Date: Sat, 4 Jan 1997 06:31:00 -0500 (EST) Message-Id: <199701041130.GAA01809@cypress.skiles.gatech.edu> To: zsh-workers@math.gatech.edu Subject: forwarding to the list. Date: Sat, 04 Jan 1997 06:30:51 -0500 From: Richard Coleman Resent-Message-ID: <"nFOwS.0.951.pzZpo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2719 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu I think the mailing list manager thought this was a subscription request, so I don't think it got through. So I'm forwarding it to the list. rc ------- Forwarded Message From: Xris Laas Sender: The Root Of All Evil Subject: Compctl for tar -- how to submit to contrib? To: zsh-workers@math.gatech.edu I wrote a pretty good (not bugfree, but works 99% of the time for me) compctl function. It semi-parses the options, and if the action is extract (x), list (t), or diff (d), it completes other arguments as files *within* the archive. Of course, it doesn't work with the archive as STDIN (-), for obvious reasons. I'm not sure how to submit it to the contrib archive/source distribution, but I figured if I post it on the list, it'll make its way there eventually. Here it is: Filename: tar-complete-function ---CUT HERE--- #!/bin/zsh # tar-complete-function # This is used with the compctl command. Put this file into your Zsh # function autoload directory, and put this in your .zshrc: # # compctl -K tar-complete-function \ # -x 'C[-1,-*C][-1,--directory]' -g '(|.)*(-/)' \ # - 'C[-1,-*f][-1,--file], p[2] W[1,*f]' -f \ # - 'C[-1,-*T][-1,--files-from]' -f \ # - 'C[-1,-*X][-1,--exclude-from]' -f \ # - 'c[-1,--use-compress-program]' -c \ # -- tar # autoload tar-complete-function # # I also like to use these aliases with this: # alias untar='tar xvf' # alias lstar='tar tvf' # alias zuntar='tar xzvf' # alias zlstar='tar tzvf' local comp cmdline action file zopt list elem comp=$1 read -Ac cmdline set $cmdline shift 1=${1#-} action=${1[1]} 1=-$1 file="" while [[ "$1" != "" ]]; do if [[ $1 == -*f* && $1 != --* ]]; then file=${1#-*f} if [[ "$file" == "" ]]; then file=$2 shift fi elif [[ "$1" == "--file" ]]; then file=$2 shift fi shift done if [[ "$file" == "" ]]; then file=- fi case $action in A) reply=(${comp}*.tar) ;; c|r|u) reply=(${comp}*) ;; d|t|x) if [[ "$file" == "-" ]]; then reply=(${comp}*) else if [[ $file == (|.)*.(gz|tgz|z|taz|Z|taZ) ]]; then zopt=z; fi list=(`tar t${zopt}f $file`) reply=() for elem in $list; do if [[ $elem == ${comp}* ]]; then reply=($reply $elem); fi done fi esac ---CUT HERE--- -- ... that whenever any form of government becomes destructive of these ends, it is the right of the people to alter or to abolish it, and to institute new government, laying its foundation on such principles, and organizing its powers in such form, as to them shall seem most likely to effect their safety and happiness. -- Thomas Jefferson, Prologue, "Declaration of Independence" { Chris "Xris" Laas }----{ chrisl@cybercom.net }----{ xris@qfl.com } ------- End of Forwarded Message