zsh-users
 help / color / mirror / code / Atom feed
* tar compctl
@ 1998-01-20 12:00 Niall Smart
  1998-01-20 17:51 ` CVS compctl Mirar
  0 siblings, 1 reply; 6+ messages in thread
From: Niall Smart @ 1998-01-20 12:00 UTC (permalink / raw)
  To: zsh-users

Hi,

Here's a GNU tar compctl I hacked up, it completes compressed tar files
after something like -xzvf, plain tar files after something like -xvf
and directories after -C, and "-xzvf" otherwise.

compctl -k '(-xzvf)' -x 'C[-1,*z*]' -g '*.(tgz|tar.(Z|gz))' \
	- 'C[-1,*x*]' -g '*.tar' - 'c[-1,-C]' -g '*(/)' -- tar

Regards

Niall


^ permalink raw reply	[flat|nested] 6+ messages in thread

* CVS compctl
  1998-01-20 12:00 tar compctl Niall Smart
@ 1998-01-20 17:51 ` Mirar
  1998-01-23 21:22   ` man compctl Thomas Köhler
  0 siblings, 1 reply; 6+ messages in thread
From: Mirar @ 1998-01-20 17:51 UTC (permalink / raw)
  To: zsh-users

Here is mine for CVS:

cvsflags=(-H -Q -q -r -w -l -n -t -v -b -e -d)
cvscmds=(add admin checkout commit diff history import export log rdiff \
            release remove status tag rtag update ci co annotate)
cvsignore="*~ *# .#* *.o *.a CVS . .."

compctl -k "($cvscmds $cvsflags)" \
    -x "c[-1,-D]" -k '(today yesterday 1\ week\ ago)' \
    - "c[-1,-m]" -k '(bugfix cosmetic\ fix ... added\ functionality foo)' \
    - "c[-1,-F]" -f \
    - "c[-1,-r]" -K cvsrevisions \
    - "c[-1,-I]" -f \
    - "R[add,;]" -k "(-k -m)" -K cvsaddp \
    - "R[admin,;]" -K cvstargets -g '*(/)' \
    - "R[checkout,;]" -k "(-A -N -P -Q -c -f -l -n -p -q -s -r -D -d -k -j)" \
	-K cvsrepositories \
    - "R[co,;]" -k "(-A -N -P -Q -c -f -l -n -p -q -s -r -D -d -k -j)" \
	-K cvsrepositories \
    - "R[commit,;]" -k "(-n -R -l -f -m -r)"  -K cvstargets -g '*(/)' \
    - "R[ci,;]" -k "(-n -R -l -f -m -r)"  -K cvstargets -g '*(/)' \
    - "R[diff,;]" -k "(-l -D -r -c -u -b -w)" -K cvstargets -g '*(/)' \
    - "R[history,;]" \
        -k "(-T -c -o -m -x -a -e -l -w -D -b -f -n -p -r -t -u)" \
        -K cvstargets -g '*(/)' \
    - "R[history,;] c[-1,-u]" -u \
    - "R[import,;]" -k "(-Q -q -I -b -m)" -f \
    - "R[export,;]" -k "(-N -Q -f -l -n -q -r -D -d)" -f \
    - "R[(r|)log,;]" -k "(-l -R -h -b -t -r -w)" -K cvstargets -g '*(/)' \
    - 'R[(r|)log,;] s[-w] n[-1,,],s[-w]' -u -S , -q \
    - "R[rdiff,;]" -k "(-Q -f -l -c -u -s -t -D -r -V)" \
	-K cvstargets -g '*(/)' \
    - "R[release,;]" -k "(-Q -d -q)" -f \
    - "R[remove,;] R[-f,;]" -k "(-l -R -f)" -K cvstargets -g '*(/)' \
    - "R[remove,;]" -k "(-l -R -f)" -K cvsremovep \
    - "R[status,;]" -k "(-v -l -R)" -K cvstargets -g '*(/)' \
    - "R[tag,;]" -k "(-Q -l -R -q -d -b)" -K cvstargets -g '*(/)' \
    - "R[rtag,;]" -k "(-Q -a -f -l -R -n -q -d -b -r -D)" \
	-K cvstargets -g '*(/)' \
    - "R[update,;]" -k "(-A -P -Q -d -f -l -R -p -q -k -r -D -j -I)" \
	-K cvstargets -g '*(/)' \
    - "R[annotate,;]" -k "(-l -f -r -D)" -K cvstargets -g '*(/)' \
    -- cvs 
unset cvsflags cvscmds

compctl -K cvstargets -g '*(/)' cvstest 

cvsremovep() {
    setopt localoptions nullglob
    [[ -e CVS/Entries ]] && reply=(`(sed -ne 's:^/\([^/]*\)/[^-].*$:E\1:p' <CVS/Entries; ( ls -a1 | sed 's:^\(.*\)$:D\1:g' ) ) | sort +0.1 | uniq --skip-chars=1 -u | sed -ne 's/^E\(.*\)$/\1/p'`)
}

cvsaddp() {
    setopt localoptions nullglob
    [[ -e CVS/Entries ]] && reply=(`(sed -ne 's:^/\([^/]*\)/.*$:E\1:p' -e 's:^/\([^/]*\)/-.*$:E\1:p' <CVS/Entries; ( ls -a1 | sed 's:^\(.*\)$:D\1:g' ); (ls -ad1 $(echo "$cvsignore"; cat .cvsignore 2>/dev/null ) 2>/dev/null | sed 's:^\(.*\)$:I\1:g' ) ) | sort +0.1 | uniq --skip-chars=1 -u | sed -ne 's/^[^I]\(.*\)$/\1/p'`)
}

cvstargets() {
    local nword args prefix
    setopt localoptions nullglob
    read -nc nword; read -Ac args
    echo "$args[$nword]" | sed -ne "s:^\(.*\)/[^/]*$:\1:" | read prefix
    reply=()
    [[ -e ./$prefix/CVS/Entries ]] && reply=(`sed -ne 's:^/\([^/]*\)/[^-].*$:'$prefix'\1:p' <./$prefix/CVS/Entries`)
}

cvsrevisions() {
    reply=($(cvs -q status -vl . | sed -e '/=======/,/Existing Tags/d' | \
             awk '{ print $1 }' ))
}

cvsrepositories() {
    local root dirs
    root=$CVSROOT
    [[ -e CVS/Root ]] && root=`cat CVS/Root`
    reply=($(echo $root/* |  sed -e 's/CVSROOT//' -e 's:'$root'/*::g') \
    	$(awk '{ print $1 }' <$root/CVSROOT/modules | sed 's/^#.*$//g'))
}


^ permalink raw reply	[flat|nested] 6+ messages in thread

* man compctl
  1998-01-20 17:51 ` CVS compctl Mirar
@ 1998-01-23 21:22   ` Thomas Köhler
  1998-01-24 11:37     ` Mirar
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Köhler @ 1998-01-23 21:22 UTC (permalink / raw)
  To: zsh-users

Hello all,
here's my completion for manpages.

# completion for manpages

####
# if ~/tmp/_man_ is too old then remove it and create a new one later
find ~/tmp -mtime 14 -name "_man_" -exec rm -f {} \;

createman () {
   echo "creating ~/tmp/_man_"
   find /usr/man -type f > ~/tmp/_man_
   find /usr/local/man -type f >> ~/tmp/_man_
   find /usr/X11R6/man -type f >> ~/tmp/_man_
   sed -e "s/.*\///" -e "s/\.gz//" -e "s/\.[^.]*$//" ~/tmp/_man_ | sort | uniq > ~/tmp/_man2_
   rm -f ~/tmp/_man_
   (for i in `cat ~/tmp/_man2_` ; do echo -n "$i " ; done) > ~/tmp/_man_
   rm -f ~/tmp/_man2_
}
if [ ! -f ~/tmp/_man_ ] ; then createman ; fi
####
man_pages=(`cat ~/tmp/_man_`)
compctl -f -k man_pages man

Remarks:
the first part (#### - ####) should better be put in a cron job or in
your .zlogout (if you don't have access to crontab) - it may take some
time to process those finds :-)

CU,
Thomas

-- 
  -- Thomas Köhler   Email:  jean-luc@picard.franken.de
          <><                     jean-luc@mayn.de
   IRC: jeanluc  Channels:  #star_trek #linuxger #ixthys #knf
             WWW: http://home.pages.de/~jeanluc/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: man compctl
  1998-01-23 21:22   ` man compctl Thomas Köhler
@ 1998-01-24 11:37     ` Mirar
  1998-01-24 11:57       ` misc compctl Mirar
  0 siblings, 1 reply; 6+ messages in thread
From: Mirar @ 1998-01-24 11:37 UTC (permalink / raw)
  To: Thomas Köhler; +Cc: zsh-users

> # completion for manpages

I wrote one that demands kind-of fast computers, but i was lazy:

#------------------------------------------------------------------------------
compctl -k "(- -a -d -F -l -r -t -M -T -s -k -f)" \
	-K compmanfull \
	-x "C[-1,-s^],s[-s]" -K compmansections \
	- "R[-f,;]" -f \
	- "R[-k,;]" -k "()" \
	- "R[-s,;]" -K compmansection \
	-- man

compmanfull() 
   { reply=(${^manpath}/man*/*(N:t:r)) }

compmansections() 
{  
   reply=( ${^manpath}/man*(N/) )
   reply=( ${reply##*/man} )
}

compmansection()
{
   local a
   read -Ac a
   echo $a | sed -ne 's/^.* -s\([^ ]*\).*$/\1/p' | read prefix
   reply=(${^manpath}/man$prefix/*(N:t:r))
}
#------------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: misc compctl
  1998-01-24 11:37     ` Mirar
@ 1998-01-24 11:57       ` Mirar
  0 siblings, 0 replies; 6+ messages in thread
From: Mirar @ 1998-01-24 11:57 UTC (permalink / raw)
  To: zsh-users

And here is ssh, nslookup, other network stuff and gdb:


hosts=(fixed list of my computers)
or
hosts=($(echo ls $(echo | nslookup | sed -n '1s/^[^.]*\.\(.*\)$/\1/p') | nslookup 2>&1 | sed '1,4d' | awk '{print $1}' | grep -v '\.$' | grep -v '>' | sort))
or something...

compctl -k "($hosts -l -n -a -x -i -t -v -q -f -e -c -p -L -R -C -o)" \
	-x "c[-1,-l]" -u \
	- "c[-1,-i]" -f \
	- "c[-1,-e]" -k "(~ none)" \
	- "c[-1,-c]" -k "(idea des 3des tss arcfour none)" \
	- "c[-1,-p]" -k ports \
	- "c[-1,-L] c[-1,-R] c[-1,-o]" -k "()" \
	-- ssh

compctl -k hosts \
	-x "n[1,-class=]" -k "(any in chaos hesiod)" \
	- "n[1,-query=]" -k "(a cname hinfo md mx mb mg minfo ns ptr soa txt uinfo wks any)" \
	-- + -k "(-query= -all\  -class= -d2\  -nod2\  -debug\  -nodebug\  -defname\  -nodefname\  -domain= -ignoretc\  -noignoretc\ )" -Q -S '' \
	nslookup

compctl -k hosts \
	-x "C[-1,[^-]*] p[2,-1]" -k ports \
	-- + -k "(-8 -E -L -a -d -e -l -n -r)" \
    	telnet

compctl -k "($hosts -s -d -l -L -n -r -R -v -i -I -t)" ping

compctl -x 'N[-1,@]' -k hosts - 's[]' -u -S '' -- finger talk

compctl -g "*(*)" -k "(-help -nx -q -batch -cd -f -b -tty -exec -se -core -symbols -c -x -d)" \
	-x "p[1],C[-2,(-cd|-directory|-core|-c|-se|-exec|-symbols|-command|-x)]" -g "*(*)" -k "(-help -nx -q -batch -cd -f -b -tty -exec -se -core -symbols -c -x -d)" \
	- "C[-1,(-cd|-directory)]" -g '*(-/)' \
	- "C[-1,(-core|-c)]" -g 'core*' \
	- "C[-1,(-se|-exec)]" -g '*(*)' \
	- "C[-1,(-symbols|-command|-x)]" -g '*' \
	- "C[-1,[^-]*]" -g "core*" \
	-- gdb


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: misc compctl
@ 1998-01-29  2:33 Alexius Ludeman
  0 siblings, 0 replies; 6+ messages in thread
From: Alexius Ludeman @ 1998-01-29  2:33 UTC (permalink / raw)
  To: zsh-users

Since we're all mentioning our little tricks.  Here is what i use:

autoload createcomphosts
compctl -K createcomphosts telnet rsh rup ping traceroute ssh xrsh

function createcomphosts()
   {
   if [ $comphost"X" = "X" ]; then
      comphost=(`ypcat netgroup | cut -d, -f 1 | cut -c2-` other hosts
                not in netgroup map )
      reply=( $comphost )
   else
      reply=( $comphost )
   fi
}

Since our netgroup map is quite large (3569 hosts).  This is dynamic
enough and is only created on first completion and doesn't bloat all
the shells.

Although I do get a strange error sometimes which I haven't entirely
looked into, but I'll get an error about "zsh: condition expected:
somerandomhostname".

Another strange behavior is when I use the push-line feature and bind
ctrl-p to it.  Now when I first type a line and hit ctrl-p it'll push
the command I was working on away as designed.  But say I start
scrolling through the history then ctrl-p become previous history.

thank you drive through,
Lex


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-01-29  2:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-20 12:00 tar compctl Niall Smart
1998-01-20 17:51 ` CVS compctl Mirar
1998-01-23 21:22   ` man compctl Thomas Köhler
1998-01-24 11:37     ` Mirar
1998-01-24 11:57       ` misc compctl Mirar
1998-01-29  2:33 Alexius Ludeman

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).