zsh-workers
 help / color / mirror / code / Atom feed
From: Richard Coleman <coleman@math.gatech.edu>
To: zsh-workers@math.gatech.edu
Subject: forwarding to the list.
Date: Sat, 04 Jan 1997 06:30:51 -0500	[thread overview]
Message-ID: <199701041130.GAA01809@cypress.skiles.gatech.edu> (raw)

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 <chrisl@cybercom.net>
Sender: The Root Of All Evil <root@cybercom.net>
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


             reply	other threads:[~1997-01-04 11:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-04 11:30 Richard Coleman [this message]
1997-01-04 11:39 ` (off-topic) " Daniel Reish

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199701041130.GAA01809@cypress.skiles.gatech.edu \
    --to=coleman@math.gatech.edu \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).