Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
forwarding to the list.
- X-seq: zsh-workers 2719
- From: Richard Coleman <coleman@xxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: forwarding to the list.
- Date: Sat, 04 Jan 1997 06:30:51 -0500
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@xxxxxxxxxxxx>
Sender: The Root Of All Evil <root@xxxxxxxxxxxx>
Subject: Compctl for tar -- how to submit to contrib?
To: zsh-workers@xxxxxxxxxxxxxxx
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@xxxxxxxxxxxx }----{ xris@xxxxxxx }
------- End of Forwarded Message
Messages sorted by:
Reverse Date,
Date,
Thread,
Author