[net.sources] Mac-like guide for UNIX

puder@logic.DEC (Karl Puder) (10/03/85)

This tidbit is being posted for oster%ucblapis.CC@Berkeley.  Kudos and
complaints to him, I'm just a middle-man.

On the macintosh, there is an "info" field on each file, in which you
can put a short description of the file.  I have implemented this on Unix:
The command "guide" types out the file ".guide" which contains a oneline
description of every file in the directory.
The command "makeguide" updates the .guide file, inserting the names of
any new files in the directory, and marking lines of formerly existing
files with a '#'.

---------------- cut here ----------------
#! /bin/sh
# The rest of this file is a shell script which will extract:
# .guide Makefile guide makeguide makeguide.awk
# when you run it with /bin/sh.
 
echo x - .guide
sed 's/^X//' > .guide << 'EOF'
XMakefile	- makefile for this directory
Xguide		- print .guide file for current directory
Xmakeguide	- update a .guide file
Xmakeguide.awk	- used in makeguide
Xunmore		- break up a more-chive
Xunmore.c	- source code for unmore
EOF
echo x - Makefile
sed 's/^X//' > Makefile << 'EOF'
Xguide : .guide
X.guide : .
X	makeguide
Xunmore : unmore.o
X	cc -o unmore unmore.o
EOF
echo x - guide
sed 's/^X//' > guide << 'EOF'
Xmore .guide
EOF
echo x - makeguide
sed 's/^X//' > makeguide << 'EOF'
Xmv .guide .tmp
Xls >> .tmp 
Xsort .tmp | awk -f $HOME/bin/makeguide.awk > .guide 
Xrm .tmp
Xtouch .guide
Xecho new .guide file is made and ready for editing.
X# the .guide file has one line of comment per file in the directory.
X# if a new file was created, this adds it to the .guide file
X# if an old file was deleted, a # is placed in its comment line.
X# Author: David Oster lapis!oster@ucbvax
EOF
echo x - makeguide.awk
sed 's/^X//' > makeguide.awk << 'EOF'
XBEGIN { false = 0; true = 1; lin1 = false;}
X$2 == "" {
X	if(lin1 && $1 != prev){ print(prev); }
X	prev = $1;
X	lin1 = true; 
X  }
X$2 != "" {
X	if(lin1 && prev != $1){ print(prev); }
X	printf( "%s\t", $1);
X	if(length($1) < 8 ){ printf("\t"); }
X	if(prev != $1 && $2 != "#")printf("# ");
X	for(i=2;i <= NF-1;i++)printf("%s ",$i);
X	printf("%s\n",$NF);
X	lin1 = false;
X  }
XEND { if(lin1){ print(prev); } }
EOF