Pipe ipkg/gpkg through less for Zsh pkgtools as well
[pkgusr] / etc / pkgusr / zsh / zsh-pkgtools
index 1f11308..2b0dfd6 100644 (file)
@@ -20,6 +20,7 @@ H-pkg ()
         gpkg [PKG]    -- print general notes of PKG.
         wpkg [PKG]    -- print PKG website URL.
         dpkg [PKG]    -- print PKG dependencies.
+       pkgwant [PKG] -- print a list of packages that depend on PKG
         pkgrepo [PKG] <t> -- print the source repo location of PKG
                              with optional 2nd arg non-nil, also print
                              repo type.
@@ -118,7 +119,7 @@ ipkg()
         else
                 local top=$(grep -n "Install Notes" ~$argv[1]/.project|cut -d: -f1)
                 local bot=$(grep -n "General Notes" ~$argv[1]/.project|cut -d: -f1)
-                sed -n ${top},${bot}p  ~$argv[1]/.project
+                sed -n ${top},${bot}p  ~$argv[1]/.project|less
         fi
 }
                
@@ -131,7 +132,7 @@ gpkg()
         else
                 local top=$(grep -n "General Notes" ~$argv[1]/.project|cut -d: -f1)
                 local bot=$(grep -n "CONTENTS" ~$argv[1]/.project|cut -d: -f1)
-                sed -n ${top},${bot}p ~$argv[1]/.project
+                sed -n ${top},${bot}p ~$argv[1]/.project|less
         fi
 }
 
@@ -169,6 +170,19 @@ pkgrepo()
         fi
 }
 
+pkgwant()
+{
+       if [[ $ARGC -lt 1 || $ARGC -gt 1 ]]; then
+               echo Invalid or mission argument >&2
+               echo "Usage: $0 [PKG]" >&2
+               return 1
+       fi
+
+       for p in $(lpkg); do
+               dpkg ${p} | grep -wq $argv[1] && print ${p}
+       done
+}
+
 xtar()
 {
         if [[ $ARGC -lt 1 || $ARGC -gt 1 ]]; then
@@ -187,7 +201,7 @@ xtar()
                (tar)   opts=xf ;;
                (gzip)  opts=zxf ;;
                (bzip2) opts=jxf ;;
-               (xz)    opts=Jxf ;;
+               (xz|XZ) opts=Jxf ;;
                (*)
                        # try lzma
                        if lzmainfo ${fname} &>/dev/null; then
@@ -220,7 +234,7 @@ vtar()
                 (tar)   opts=tvvvf ;;
                 (gzip)  opts=ztvvvf ;;
                 (bzip2) opts=jtvvvf ;;
-               (xz)    opts=Jtvvvf ;;
+               (xz|XZ) opts=Jtvvvf ;;
                 (*)
                        # lzma.  Here because lzmainfo is too stupid
                        if lzmainfo ${fname} &>/dev/null; then
@@ -256,7 +270,7 @@ pkgsu()
                 echo "Usage: $0 [PKGUSR]" >&2
                 return 1
         else
-                ssh -l root localhost -t su $argv[1]
+                ssh -l root localhost -t su $argv[1]
         fi
 }
 
@@ -272,7 +286,7 @@ pkg_install()
         fi
 }
 
-alias pkg_ldconfig='ssh -l root localhost -t ldconfig'
+alias pkg_ldconfig='ssh -l root localhost ldconfig'
 
 ### End