home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume4 / blachman / part01 next >
Encoding:
Internet Message Format  |  1989-02-03  |  36.9 KB

  1. Path: xanth!mcnc!rutgers!gatech!cwjcc!hal!ncoast!allbery
  2. From: karl@cs.duke.edu (Karl Ramm)
  3. Newsgroups: comp.sources.misc
  4. Subject: v04i040: collected csh / sh / etc. goodies (1 of 3)
  5. Message-ID: <8808281545.AA09309@romeo.cs.duke.edu>
  6. Date: 28 Aug 88 15:45:40 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: karl@cs.duke.edu (Karl Ramm)
  9. Lines: 1074
  10. Approved: allbery@ncoast.UUCP
  11.  
  12. Posting-number: Volume 4, Issue 40
  13. Submitted-by: "Karl Ramm" <karl@cs.duke.edu>
  14. Archive-name: blachman/Part1
  15.  
  16. [Not shar'ed; I don't recommend submitting things this way.... ++bsa]
  17.  
  18. Several people have been asking about Nancy Blachman's collection of
  19. csh/sh tricks and interesting programs.. so, here goes..
  20.  
  21. From: Nancy Blachman <decvax!decwrl!sun!idi!resonex!nancy@Ucb-Vax.ARPA>
  22. To: net.unix, net.unix-wizards, net.sources
  23. Subject: Actual tricks, shells, csh aliases and the like, 1 of 3
  24. Date: 16 Oct 84 21:20:53 GMT
  25. Organization: Resonex Inc., Sunnyvale, CA
  26.  
  27. > [Know anybody with a GREAT .login or .cshrc?]
  28.  
  29. > I'm interested in collecting the little tricks, shell scripts, awk
  30. > hacks, csh aliases, and such that people have built to make their daily
  31. > life a little easier or more automatic.  Being a fairly new system
  32. > administrator I don't have the big toolbox that years of messing around
  33. > will leave you with.  If you have any hacks you're proud of (or that
  34. > you aren't proud of, but which work anyway), and you're willing to make
  35. > them public, mail them to me.  I'll collect, collate, shuffle, sort,
  36. > munge, judge, select and discard them and then "summarize to the net".
  37.  
  38. This article concentrates on  aliases, and .cshrc and .login files I received
  39. in response to my solicitation. The second article in this series focuses 
  40. shell scripts. The third article centers on C programs and awk scripts.
  41.  
  42. /\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\/
  43. > Nancy Blachman {allegra,hplabs,ihnp4,sun}!resonex!nancy  (408)720 8600 x37 <
  44. /\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\/
  45.  
  46. ::::::::::::::
  47. aliases/1
  48. ::::::::::::::
  49. Date: Thu, 13 Sep 84 07:27:35 est
  50. From: ihnp4!pur-ee!davy (Dave Curry)
  51. To: ihnp4!resonex!nancy
  52. Subject: aliases
  53.  
  54. Nancy:
  55.  
  56.     Here's a few handy aliases to put your current working
  57. directory into your prompt:
  58.  
  59. alias cd chdir \!:\* \; set prompt='${cwd}\[!\]\ ' \; setenv CWD '$cwd'
  60. alias pd pushd \!:\* \; set prompt='${cwd}\[!\]\ ' \; setenv CWD '$cwd'
  61. alias pp popd \!:\* \; set prompt='${cwd}\[!\]\ ' \; setenv CWD '$cwd'
  62.  
  63. These put the current directory into the environment also, this is
  64. for an editor used here locally which uses this information.  You can delete
  65. that part if you don't need it.
  66.  
  67. --Dave Curry
  68. ihnp4!pur-ee!davy
  69.  
  70.  
  71.  
  72. ::::::::::::::
  73. aliases/2
  74. ::::::::::::::
  75. From: hplabs!sdcrdcf!sdcsvax!greg (Greg Noel)
  76. Date: Thu, 13 Sep 84 10:57:51 pdt
  77. Return-Address: ucbvax!sdcsvax!greg or Greg@NOSC
  78. Organization: NCR Corporation, Torrey Pines
  79. To: sdcrdcf!hplabs!resonex!nancy
  80. Subject: Re: Tricks, shell and awk scripts, csh aliases and the like
  81.  
  82. I have three little gems from my bag of tricks that I'd like to show you,
  83. all for the C shell.  The first is an alias for the `pwd' command:
  84.     alias pwd    echo \$cwd
  85. The built-in variable `cwd' always contains the current working directory,
  86. and since `echo' is a built-in command, this is MUCH faster than invoking
  87. a program to calculate the actual location.  The only problem (and I don't
  88. have a solution) is that it gets confused by symbolic links to directories.
  89.  
  90. The second one is something that turns the directory structure from something
  91. passive into something active:
  92.     alias come    if -e .greg_come source .greg_come
  93.     alias go    if -e .greg_go   source .greg_go
  94.     alias cd    go \; set prev = \$cwd \; chdir \!\* \; \
  95.                 echo \$prev ==\\\> \$cwd \; come
  96. What this does is cause the shell to look for a specific file whenever it
  97. transfers into a directory, and if it is there, source it.  Also, whenever
  98. you leave a directory, it looks for a different file and sources that before
  99. leaving.  I use this to set up location-specific aliases or to have something
  100. happen auto-magicly whenever I work in some diretory -- for example, changing
  101. into my `play' directory invokes a menu that will set up the environment and
  102. run game programs -- different save files for `rogue' or other stuff that
  103. I don't want to carry around with me all the time.  It's more flexible than
  104. it seems at first glance; the only thing I can suggest is to try it and you
  105. will keep finding new ways to use it.
  106.  
  107. The last one is really a replacement for the `pushd' and `popd' commands --
  108. I didn't like the way they worked, so I did these.  It seperates the action
  109. of pushing a directory from the action of changing directories.  I wanted
  110. this since I also have a whole bunch of aliases to move between widely-
  111. seperated portions of the filesystem (something I do a lot) and it was
  112. easier for me to type `push; u test' (which pushes the current directory
  113. and takes me into the `test' subdirectory of something interesting) than
  114. to type `pushd /long/complicated/path/test'.  This isn't terribly original,
  115. but the gem, and something I find VERY useful is the `back' command, which
  116. takes you to the directory you last left, so you can bouce back and forth
  117. between two directories -- one is the source location and one the test
  118. location, for example.  Anyway, here's what it looks like:
  119.     alias push    set dirstack = \( \$cwd \$dirstack \) \; \
  120.                 echo Pushing \\\[\$\#dirstack] \$cwd \; \!\*
  121.     alias pop    cd \$dirstack\[1] \; set dirstack = \( \$dirstack\[2-] \)
  122.     alias back    set dirstack = \( \$prev \$dirstack \) \; pop
  123.     alias pp    set x = \$dirstack\[1] dirstack\[1] = \$cwd \; cd \$x
  124. Notice that it interacts with the previous alias for `cd' in that it expects
  125. the variable `prev' to have the previous directory (which is what `cd' leaves
  126. in it).  The `pp' alias is sometimes useful -- it pushes the current directory
  127. while transfering to the old top of stack, a simultaneous push-pop.
  128.  
  129. I hope you found these interesting and entertaining.
  130.  
  131. -- Greg Noel, NCR Torrey Pines       Greg@sdcsvax.UUCP or Greg@nosc.ARPA
  132.  
  133. ::::::::::::::
  134. cshrc/1
  135. ::::::::::::::
  136. From: <hplabs!tektronix!jerryp>
  137. Date: Thursday, 13 Sep 84 09:48:55 PDT
  138. To: resonex!nancy, jerryp
  139. Subject: Re: Tricks, shell and awk scripts, csh aliases and the like
  140.  
  141. Nancy,
  142.  
  143. I'll mail you a few .cshrc and .login files.  Unfortunately, I'm short on
  144. time... so I can't comment a lot... but I'd be glad to answer any questions
  145. you've got about how they work.
  146.  
  147. A summary of them:
  148.  
  149. 1)  This .cshrc file comes from the tektronix!tekred machine in Redmond,
  150. Oregon.  Its neat feature is that, when a user "su"'s to someone else's
  151. account, their prompt changes
  152. from    %
  153. to    account>
  154. where the "su"'d name appears before the >.  Very nice, I think.
  155.  
  156. Also, they do a standard thing around here.  The first line [if ($?prompt)]
  157. checks to see if the .cshrc is being scanned by an interactive shell.  If so,
  158. the commands below are executed.  If not (like a shell escape from "vi"), the
  159. commands aren't executed.  This really speeds up shell escapes!  (I do the
  160. same thing, in a different way, in my .cshrc file.)
  161.  
  162.  
  163. 2)  This is my .login file.  I should mention that I've got my own calendar
  164. system that's updated every morning at 1 AM by "at".  It sits in my
  165. ".calendar" directory.  You'll see a lot of that stuff in the .login file.
  166.  
  167.  
  168. 3 & 4)  I have *two* .cshrc files.  One, ".cshrc", is the standard file.  It
  169. contains a limited list of aliases and setup commands.  The other, ".cshrc2",
  170. is one I source when I'll be logged on for a long time and doing a lot of
  171. work.  The .cshrc2 has time-saving aliases like "alias m more" in it.  
  172.  
  173. At login, the .cshrc is always read.  This sets my prompt to something like
  174.     <directory,#>
  175. where # is the C-shell history number.  Also, since my system is so busy, I
  176. have a "quick login" setup in .cshrc to let me see my mail immediately and
  177. logout without doing anything else, if I want to.  This quick-login has a
  178.     $
  179. prompt set... the Bourne-shell prompt.
  180.  
  181. If I want an extended login, I execute the alias "res" (from .cshrc).  It sets
  182. alarms automatically (for meetings, etc... from my .calendar directory) and
  183. re-sets my prompt to something like
  184.     [directory,#]
  185. That way, I know that I've got all my aliases available.
  186.  
  187. Since my system is overloaded, this dual-.cshrc system saves me time and
  188. hassle... .cshrc2 takes a long time to source.
  189.  
  190.  
  191. --Jerry Peek, UNIX Training Instructor, Tektronix, Inc.
  192. US Mail:   MS 76-036, P.O. Box 500, Beaverton, OR 97077
  193. uucp:      {allegra,decvax,hplabs,ihnp4,mit-eddie,ucbvax}!tektronix!jerryp
  194. CSnet:     jerryp@tek
  195. ARPAnet:   jerryp.tek@csnet-relay
  196. Phone:     503/627-1603
  197.  
  198.  
  199. ---------------------------------------------------------------------------
  200. FILE #1 (.cshrc):
  201.  
  202. if ($?prompt) then
  203.     set history=20
  204.     set path=(. $home/bin /usr/local /usr/tek /usr/public /usr/ucb /bin /usr/bin)
  205.     set mail=(300 /usr/spool/mail/$home:t /etc/motd)
  206.     source ~/.aliases
  207.  
  208.     set prompt=`whoami | sed -e 's/ .*//' -e 's/user=//'`
  209.     if ($prompt == $user || $prompt == "") then
  210.         set prompt="% "
  211.     else
  212.         set prompt="$prompt> "
  213.     endif
  214. endif
  215. ---------------------------------------------------------------------------
  216. FILE #2 (.login):
  217. uptime            # show system load
  218. set ignoreeof        # do not logout on EOF (^D)
  219. set noclobber        # do not overwrite files with > or >>
  220. cp ~/.exrc8 ~/.exrc    # set up vi/ex to environment in ~/.exrc8
  221. setenv EDIT /usr/ucb/vi    # set default editor to vi
  222. setenv PRINTER uph    # if type "man -Tlpr", use "uph" to store for printing
  223. setenv NEWSBOX ~    # save news (readnews "s") in home directory or beneath
  224.  
  225. set noglob; eval `tset -srQm 'plugboard:?4025'`; unset noglob
  226.  
  227. stty new crt        # new tty driver, crt terminal, see newtty(4)
  228. stty tostop hup     # stop background jobs on output, hangup hw on logout
  229. limit filesize 2000    # do not write file > 2,000,000 bytes
  230. limit coredumpsize 0    # prevent core dumps when csh bombs
  231. touch .llog        # set correct last login time for finger
  232. if ($TERM == 'tek4023' || $TERM =~ aaa*inv ) then
  233.     # KEEP more FROM USING THE ul OPTION AND MESSING UP DISPLAY:
  234.     setenv MORE -u
  235. else if (($TERM == qume5) || ($TERM == dumb)) then
  236.     mesg n
  237.     exit 0
  238. endif
  239.  
  240. # immediate notification (every 60 seconds) of mail:
  241. set mail = (60 /usr/spool/mail/$user /etc/motd)
  242.  
  243. # check /etc/motd for changes; if any, show them and (maybe) add to calendar:
  244. diff ~/.calendar/last.motd /etc/motd >! /tmp/motd.diff
  245. if ( $status != 0 ) then
  246.     echo "< = old MOTD ... > = new MOTD"
  247.     more /tmp/motd.diff
  248.     echo "To read the new MOTD into the calendar, answer y.  To ignore it, answer q."
  249.     echo -n "Otherwise, hit RETURN: "
  250.     set ans = $<
  251.     if ($ans == "y") then
  252.         cat /etc/motd | tee -a ~/.calendar/calendar >! ~/.calendar/last.motd
  253.         vi + ~/.calendar/calendar
  254.         echo "To reset *today's* calendars, type 'calendar.set -F'."
  255.     else if ($ans == "q") then
  256.         cat /etc/motd >! ~/.calendar/last.motd
  257.     endif
  258. endif
  259.  
  260. echo "--------------------"
  261. inc        # put new mail, if any, in ~/.mail/inbox
  262.  
  263. echo "--------------------"
  264.  
  265. set time = 10    # for jobs that take longer than 10, show how long
  266. # IF THERE ARE LOGIN MESSAGES, SHOW THEM:
  267. if !(-z ~/.calendar/mesg.login) then
  268.     echo "Here are the login messages, "`date '+%a %D'`
  269.     echo ""
  270.     doublespace ~/.calendar/mesg.login
  271. endif
  272.  
  273. echo "For an uptime graph, type 'upgr'."
  274. ---------------------------------------------------------------------------
  275. FILE #3 (.cshrc):
  276. # if this is a non-interactive shell, quit.
  277. if ( ! $?prompt) exit 0
  278.  
  279. # save login system search path, removing leading "." (thanx to tekig!danr):
  280. if ( ! $?SYSPATH ) setenv SYSPATH "$path[2-]"
  281.  
  282. # set default places to find commands (put current and .bin directories first):
  283. set path=(. ~/.bin $SYSPATH /usr/public{,/texthelp} /usr3/{barbaraz/.,tcomm/}bin)
  284.  
  285. # CHECK FOR QUICK LOGIN:
  286. if (! $?LOGGEDIN) then
  287.     echo -n "For quick login (Bourne shell), answer y; otherwise, press RETURN: "
  288.     if ( "$<" =~ y* ) then
  289.         echo "To continue with login, press control-D; to logout, type 'stty 0'"
  290.         /bin/sh -i
  291.         echo "Continuing with standard login..."
  292.     endif
  293. endif
  294. setenv LOGGEDIN x
  295.  
  296. # set cd search path for directory names which aren't sub-directories:
  297. set cdpath=(~ `finddirs ~/training{,/*} /usr3/tcomm/unix{,/*}` ~/.bin ~/.log ~/.mail ~/stuff ~/tape*)
  298.  
  299. set history=1000    # keep the last 1000 commands in history
  300.  
  301. # use /usr/public/prompt to get massaged directory name for prompt-setting:
  302. set prompt = "<`prompt ~ $cwd`,"{\!}"> "
  303.  
  304. # edit my calendar:
  305. alias calen 'vi ~/.calendar/calendar; echo '"To reset today\'s calendars, type calendar.set -F"''
  306.  
  307. # change directory, reset prompt:
  308. alias cd 'chdir \!*; set prompt = "<`prompt ~ $cwd`,"{\!}"> "'
  309.  
  310. # add to specified .log directory
  311. alias log 'echo "Put a .ze at end of file, unless last log of this set.";vi + ~/.log/`cat ~/.log/latestlog`/\!*'
  312.  
  313. # create newterm command to allow terminal-type change
  314. alias newterm 'set noglob;eval `tset -srQ \!*`;unset noglob'
  315.  
  316. # sets alarms (if any) and sources '.cshrc2' (my other alias list)
  317. alias res '~/.bin/alarm.set ; source ~/.cshrc2'
  318.  
  319. alias todo 'vi ~/todo\!*'    # change one of the "to do" lists
  320. ---------------------------------------------------------------------------
  321. FILE #4 (.cshrc2):
  322.  
  323. # notify immediately when background jobs are finished
  324. set notify
  325.  
  326. # prompt with current directory name, history number:
  327. alias s_p 'set prompt = "[`prompt ~ $cwd`,"{\!}"] "'
  328. s_p
  329.  
  330. # set 'vi' for 4-character tabs/shifts:
  331. alias 4vi 'cp ~/.exrc{4,}; echo "MODE: programming"'
  332.  
  333. # set 'vi' for 8-character tabs/shifts:
  334. alias 8vi 'cp ~/.exrc{8,}; echo "MODE: text"'
  335.  
  336. # set 'vi' for quick work (no .exrc file):
  337. alias qvi 'rm ~/.exrc; echo "MODE: quick"'
  338.  
  339. # easy way to compile "C" programs (ring bell if filename ends with ".c"):
  340. alias C 'if ("\!*" =~ *.c) yes ;mv \!* ,\!*;echo \!*.c" SENT TO cc";cc \!*.c -o \!*;if (-e \!*) chmod 311 \!*'
  341.  
  342. # show alarms that (may be) set... and message explaining them:
  343. alias alarms 'echo "These alarms have been set:";cat ~/.calendar/mesg.alarm; \ps | fgrep ".bin/nleave"'
  344.  
  345. # change back to previous directory:
  346. alias c- 'set x=$cwd; chdir $lastdir; s_p; set lastdir=$x'
  347.  
  348. # edit my calendar:
  349. alias calen 'v8 ~/.calendar/calendar; echo '"To reset today\'s calendars, type calendar.set -F"''
  350.  
  351. # see today's calendars:
  352. alias cals 'cat ~/.calendar/mesg.*'
  353.  
  354. # save current directory for 'c-', change directory, reset prompt:
  355. alias cd 'set lastdir=$cwd; chdir \!*; s_p'
  356.  
  357. # see mail without inc'ing it:
  358. alias checkm 'see /usr/spool/mail/jerryp'    
  359.  
  360. # same as 'cd', but lists directory, too:
  361. alias cl 'set lastdir=$cwd; chdir \!*; ls -F; s_p'
  362.  
  363. # same as 'cl', but gives long list:
  364. alias cll 'set lastdir=$cwd; chdir \!*; ls -l; s_p'
  365.  
  366. alias f 'grep "^\!*" /etc/passwd'    # quick version of "finger -s"
  367.  
  368. alias H 'history -r | fgrep "\!*"'    # find something in history list
  369. alias h history 5    # show last five lines
  370. alias hi history 10    # show last ten lines
  371. alias his history 20    # show last twenty lines
  372. alias hist 'history 40|m'    # show last forty lines; pipe to 'more'
  373. alias histo 'history 70|m'    # show last seventy lines; pipe to 'more'
  374.  
  375. # send output of command to 'pr' (with command as header), then to uph:
  376. alias hpr '\!* | pr -h "\!*" | uph' 
  377.  
  378. alias j 'jobs -l >! /tmp/j$$; pushin /tmp/j$$; rm /tmp/j$$'
  379. # show job status (process numbers, too) squeezed onto one line each
  380.  
  381. alias lc 'ls *.c'    # list all C source code in this directory
  382.  
  383. # add to specified .log directory
  384. alias log 'echo "Put a .ze at end of file, unless last log of this set.";v8 + ~/.log/`cat ~/.log/latestlog`/\!*'
  385.  
  386. # list executable files, 5 columns, sorted across 80-wide line:
  387. alias lx 'lf -1 | fgrep \* | pr -t -5 -l1 -w80'
  388.  
  389. alias m more        # shortened form of 'more' command
  390.  
  391. # faster pwd (singlequotes prevent expansion before it's executed):
  392. alias pwd 'echo $cwd'
  393.  
  394. # re-start inverse video on Ann Arbors:
  395. alias reinv 'echo "[7m";clear'    
  396.  
  397. # lock terminal until ^C and login password are entered:
  398. alias somb /usr3/jos/bin/somb
  399.  
  400. alias showm 'inc;show'    # get new mail
  401.  
  402. # give more info (how much time I've used) when using "status":
  403. alias status 'source ~/.bin/status'
  404.  
  405. alias tcpr 'tcprint -p12 -m5 -ff \!* &'        # typical quick "tcprint" use
  406.  
  407. alias todo 'v8 ~/todo\!*'    # change one of the "to do" lists
  408.  
  409. alias up uptime
  410.  
  411. # make uptime graph:
  412. alias upgr '(nohup uptime_graph ~/,up`date +%m%d.%H%M` &)'
  413.  
  414. # show uptime today's graph:
  415. alias upsh 'uptime_show -20 ~/,up`date +%m%d`*'
  416.  
  417. # 'vi' for programming:
  418. alias v4 '4vi;vi \!*'
  419.  
  420. # 'vi' for standard text:
  421. alias v8 '8vi;vi \!*'
  422.  
  423. # call 'vi' with a search (must use 8vi because search requires a 'wrapscan')
  424. alias vs '8vi; vi +/\!*'
  425.  
  426. alias write '/usr4/danr/bin/rite -c \!*'   # show each character as it's typed
  427.  
  428. #UNUSED ALIASES:
  429. #alias cd 'set lastdir=$cwd;chdir \!*;set prompt="`~/.bin/prompt`"'
  430. # change to maps directory:
  431. #alias maps 'cd /usr/spool/news/lib/maps;echo "switching to newsa";su newsa;set $user=jerryp;c-'
  432. # keep "at" job from dying because of long EXINIT:
  433. #alias niterun 'setenv EXINIT "set sw=8";\niterun \!*;8vi'
  434. #alias du ~danr/bin/du    # improved version of "directory usage" query
  435. # format text, save in file".ty", then show it on the crt:
  436. #alias typeup '~/.bin/type \!* >! \!*:r; more \!*:r'
  437. # give description of 'ps' codes before doing the 'ps':
  438. #alias ps 'cat ~/.ps.man;\ps \!*'
  439. # easy way to compile and run "C" programs
  440. # (ring bell if filename ends with ".c"):
  441. #alias c 'if ("\!*" =~ *.c) yes ;mv \!* ,\!*;echo \!*.c" SENT TO cc";cc \!*.c -o \!*;echo "press ^C to stop execution";sleep 2;./\!*'
  442. # easy way to change editor environment files:
  443. #alias adde 'vi ~/.exrc\!*; set ex=(`cat ~/.exrc\!*`); setenv EXINIT "$ex"'
  444. #alias rmm '\rmm \!* &'  # remove mail in background
  445. # faster "man" listings:
  446. #alias man 'echo "man -q:"; \man -q \!*'
  447. # improved spell routine (write-protected dictionary):
  448. #alias spel 'chmod +w ~/.misspell; /usr/public/spel \!*;chmod -w ~/.misspell'
  449. # show whether using ~/.exrc4 or ~/.exrc8:
  450. #alias vi 'echo "MODE: "$EXSTAT;/usr/ucb/vi \!*'
  451. #alias comp '8vi;\comp \!*'    # set 'vi' for text before doing the 'comp'
  452. # show last ten users of "tcprint" program:
  453. #alias tcp tail /usr3/tcomm/.tcprint/log
  454. # favorite "ps" (gives PID, PPID, STAT, TT, TIME, and long description):
  455. #alias p 'ps lwx | cut -c12-22,53- | nfold'
  456.  
  457. ::::::::::::::
  458. cshrc/2
  459. ::::::::::::::
  460. Date: Thu, 13 Sep 84 02:16:31 edt
  461. From: ihnp4!seismo!umcp-cs!chris (Chris Torek)
  462. To: ihnp4!resonex!nancy
  463. Subject: Re:  Tricks, shell and awk scripts, ...
  464.  
  465. Actually Re: [Know anybody with a GREAT .login or .cshrc?]:
  466.  
  467. I don't know about *great*, but I'm probably one of the candidates for
  468. *slowest* . . . .  FYA (For Your Amusement), here's my .login and .cshrc
  469. on this machine (they're not the same on tove, gyre, gymble, and eneevax).
  470.  
  471. Chris
  472.  
  473. : Run this shell script with "sh" not "csh"
  474. PATH=:/bin:/usr/bin:/usr/ucb
  475. export PATH
  476. all=FALSE
  477. if [ $1x = -ax ]; then
  478.     all=TRUE
  479. fi
  480. /bin/echo 'Extracting .cshrc'
  481. sed 's/^X//' <<'//go.sysin dd *' >.cshrc
  482. #
  483. if ($?prompt) then
  484. echo -n '['
  485. set path=(. ~chris/bin ~chris/sys /usr/local/bin /g/local /usr/ucb /bin /usr/bin /usr/games /etc /usr/hosts)
  486. echo -n 'cshrc]'
  487. set ignoreeof history=100 time=2 mail=(10 /usr/spool/mail/chris) cdpath=(~ /g/VOTRAX ~/bin /g/chris ..) S=/usr/spool/uucp CICO=/usr/lib/uucp/uucico
  488. alias hh history;alias h 'history 20';alias j jobs;alias o popd
  489. alias status 'echo $status';alias so source;alias bye logout
  490. alias p pushd;alias done 'echo ';alias kb "rm -i .*.bak *.bak .*.CKP *.CKP"
  491. alias kc "rm -i .*.CKP *.CKP";alias e emacs;alias @@term 'kill -9 $$'
  492. alias af ~chris/af/af;alias cdl "cd \!:1;ls \!:2*";alias lsl "ls -li"
  493. alias lsa "ls -A";alias lsla "ls -lai";alias up "cd ..";alias upl "cd ..;ls"
  494. alias cdll "cd \!:1;lsl \!:2*";alias lsld "lsl -d";alias lslg "lsl -g"
  495. alias upll "cd ..;lsl";alias pl "pushd \!:1;ls \!:2*";alias z logout
  496. alias pll "pushd \!:1;lsl \!:2*";alias ol "popd;ls";alias oll "popd;lsl"
  497. alias cdla "cd \!:1;lsla \!:2*";alias v80 'echo -n "[?2l";set term=VT52'
  498. alias v132 'echo -n "[?2l";set term=VT52.132';alias ansi 'echo -n "<"'
  499. alias fix 'stty newcrt erase  kill ';alias ca 'ex "+1,.|q"' 
  500. alias own 'cp \!:1 /tmp/own$$;rm -f \!:1;mv /tmp/own$$ \!:1'
  501. alias save 'cp \!:1 \!:1.old;chmod a-w \!:1.old;chmod +w \!:1'
  502. alias c80 'echo -n "[?3l";set term=DT80';alias suspend 'suspend;dirs'
  503. alias col80 'echo -n "[?3l";colnum 80';alias a alias
  504. alias c132 'echo -n "[?3h";set term=DT80.132'
  505. alias col132 'echo -n "[?3h";colnum 132'
  506. alias hold 'echo -n "[H[J[12;20H[5mI'"'"'ll be right back[m[20H";lock;echo -n "[H[J"'
  507. alias feed '(sleep 3000;echo Feeding time\\!)&'
  508. alias open 'set noglob;eval `/usr/chris/bin/open \!:*`;unset noglob'
  509. alias loav /usr/mark/bin/load
  510. setenv VISUAL /usr/ucb/vi;setenv EDITOR /usr/local/bin/emacs
  511. setenv EPATH :/usr/chris/emacs:/usr/israel/emacs:/usr/emacs/loclib:/usr/emacs/maclib
  512. alias dir ls;alias era rm;alias printman /usr/man/printman;alias d dirs
  513. alias clx 'rm -f /tmp/X_lock.\!:1 /usr/spool/uucp/LCK..\!:1'
  514. alias aasize 'set noglob;eval `/usr/local/bin/aasize \!:1`;unset noglob'
  515. alias aasave 'set noglob;eval `/usr/local/bin/aasave \!:1`;unset noglob'
  516. alias down 'cd `echo */|awk '\''{print $1}'\''`;echo $cwd'
  517. alias downl 'down;ls';alias downll 'down;lsl';alias mark 'set \!:1=$cwd'
  518. alias lso 'lsla | sort +4 -rn';alias edenv 'source ~chris/bin/edenv'
  519. alias aibib 'echo \!*|lookbib -n -p /usr/randy/papers/airefs|page'
  520. alias checkque /usr/lib/mmdf/checkque;alias sum-dial /usr/lib/mmdf/sum-dial
  521. alias deliver 'sh -c "HOME=/ /usr/lib/mmdf/deliver \!:*"'
  522. alias ll 'ls -l';alias tm 'telnet 128.8.0.8'; alias  uptime
  523. endif
  524. umask 22
  525. if ($?prompt) then
  526.     set prompt='[\!] '
  527.     echo ''
  528. endif
  529. //go.sysin dd *
  530. made=TRUE
  531. if [ $made = TRUE ]; then
  532.     /bin/chmod 644 .cshrc
  533.     /bin/echo -n '    '; /bin/ls -ld .cshrc
  534. fi
  535. /bin/echo 'Extracting .login'
  536. sed 's/^X//' <<'//go.sysin dd *' >.login
  537. #
  538. stty erase ^H kill ^X intr  decctlq nl0 cr0 ff0
  539. cd;setenv TERMCAP /usr/chris/.termcap
  540. # cp .exrc1 .exrc
  541. # Set up the terminal
  542. # 4025=Tek4025 sd=dialup x1=Xer 1750 GG=Gigi d4=GT40 aaa=AAA else DT80
  543. # if (`slowtty` == y) then
  544. #    cp .mailrc2 .mailrc
  545. # else
  546. #    cp .mailrc1 .mailrc
  547. # endif
  548. set wantbaud=0
  549. top:
  550. switch ($TERM)
  551. case su:
  552. case network:
  553.     set wantbaud=1
  554. case sd:
  555. case unknown:
  556.     set term=`/ful/chris/bin/selterm`
  557.     goto top
  558. case 4025:
  559.     stty crt tabs;tabset.tek
  560.     breaksw
  561. case h6:
  562. case hp:
  563. case hp2623:
  564. case hp2626:
  565.     stty tabs crt
  566.     breaksw
  567. case v550:
  568.     stty crt;set prompt='[7m[\!][m '
  569.     breaksw
  570. case GG:
  571.     stty crt;unsetenv TERMCAP;set prompt='[7m[\!][m '
  572.     breaksw
  573. case d4:
  574.     set term=gt40;stty crt
  575.     breaksw
  576. case aaa:
  577. case aaa-60:
  578.     set term=aaa prompt='[7m[\!][m ';stty tabs crt;unsetenv TERMCAP
  579.     aakey -f /ful/chris/.aakeys
  580.     if (`tty` =~ /dev/tty*) then
  581.         echo -n 'Lines? [30] '
  582.         set lines=$<
  583.         if ($lines != ) then
  584.             aasize $lines
  585.         endif
  586.     endif
  587.     breaksw
  588. case h19:
  589. case h19a:
  590. case kb:
  591.     set term=h19a prompt='[7m[\!][m ';stty tabs crt crtkill
  592.     breaksw
  593. case Dq:
  594. case DT80:
  595. case D5:
  596. case vt100:
  597.     set term=DT80 prompt='[7m[\!][m '
  598.     echo -n '[?4l';stty crt
  599.     breaksw
  600. default:
  601.     unsetenv TERMCAP;echo "Wonder what $TERM is?"
  602.     breaksw
  603. endsw
  604. if ($wantbaud == 1) then
  605.     selbaud
  606. endif
  607. unset wantbaud lines
  608. # mailcount
  609. checknews
  610. setenv ROGUEOPTS 'jump,ask,terse,flush,passgo,fruit=hregfx'
  611. setenv PAGER /usr/ucb/page
  612. setenv SPELL_LISTS /ful/chris/.splist
  613. alias logout 'source /ful/chris/.logout.';alias exit logout
  614. # /usr/games/fortune
  615. w; # calend; /usr/chris/bin/ac 22:00
  616. echo ----------------------------------------------------------
  617. # rehist .history
  618. //go.sysin dd *
  619. made=TRUE
  620. if [ $made = TRUE ]; then
  621.     /bin/chmod 644 .login
  622.     /bin/echo -n '    '; /bin/ls -ld .login
  623. fi
  624.  
  625. ::::::::::::::
  626. cshrc/3
  627. ::::::::::::::
  628. Date: Fri, 14 Sep 84 14:59:01 pdt
  629. From: hplabs!sdcrdcf!sdcsvax!sdcc6!loral!hlb (Howard Brandell)
  630. To: sdcc6!sdcsvax!sdcrdcf!hplabs!resonex!nancy
  631. Subject: .cshrc
  632.  
  633. I am sending my entire .cshrc file because I have some things in it
  634. that help me out.
  635.  
  636. Firstly, note the aliases that allow me to selectively read those
  637. newsgroups of interest.  Aha! You may say I can put it all in the
  638. .newsrc file and have the system inform me when there is news and
  639. read it out simultaneously.  But, sometimes we get news during the
  640. course of the day and I like to check my favorites continuously.
  641.  
  642. Also, not the aliases for tip.  These allow me to dial my remote 
  643. locations with both spped and accuracy. As an aside,  I have
  644. created a .tiprc file which logs all my remote host conversation
  645. into a file.  In this way, nothing is lost.  Note the 'rt' command
  646. which allows me to purge tiplog.
  647.  
  648. alias a alias
  649. a sd   "msg,gju,glw,kay,sdi"
  650. a ds   "chmod 600 .signature"
  651. a es   "chmod 640 .signature"
  652. a vc   "ccalc"
  653. a m    "mail"
  654. a p    "more"
  655. a rk   "readnews -n net.kids"
  656. a ra   "readnews -n net.micro.apple"
  657. a ri   "readnews -n net.micro.pc"
  658. a rs   "readnews -n sdnet.computing"
  659. a rb   "readnews -n net.sport.baseball"
  660. a rn   "readnews -n net.columbia"
  661. a rw   "readnews -n net.wanted"
  662. a rl   "readnews -n net.legal"
  663. a r    "readnews"
  664. a logs "readnews -n net.sources -l>sources.log"
  665. a motd "cat /etc/motd|more"
  666. a h   "history -r \!*|more"
  667. a t1  "tip 561-7271"
  668. a t2   "tip 452-1869"
  669. a t3   "tip 283-1538" 
  670. a t4   "tip 692-1961"
  671. a t5   "tip 270-1166" 
  672. a t6   "tip 217-1900"
  673. a rt   "rm tiplog"
  674. a bye     logout
  675. a cd    "cd \!* ; dirs"
  676. a term    'set noglob; eval `tset -n -s \!*`'
  677. a wat    "ps -au | more"
  678. a pv    printenv
  679. a j    "jobs -l"
  680. a f    "finger|more"
  681. a l    ls -F
  682.  
  683. if ( $?prompt == 1 ) then
  684.     set prompt="\!: "
  685.     set mail=(60 /usr/spool/mail/$USER)
  686. endif
  687. set history =    24
  688. set cdpath = (. ~)
  689.  
  690. Also note the aliases for the more mundane commands, like mail
  691. and more -c.
  692.  
  693. Hope this has been of some help.  Please disregard my earlier
  694. transmission as I had some operational difficulties.  Thx.
  695.  
  696. ::::::::::::::
  697. cshrc/4
  698. ::::::::::::::
  699. From: sun!dagobah!mike
  700. Date: Mon, 17 Sep 84 23:27:05 pdt
  701. To: sun!resonex!nancy
  702. Subject: .cshrc
  703.  
  704. set mail=(10 /usr/spool/mail/$user)
  705. set path=(. ~/bin /usr/lfl/bin /usr/ucb /bin /usr/bin /usr/hosts /usr/suntool)
  706. set cdpath  = ( . .. ~ /usr /u0 /u1 /audio)
  707. set mail=(10 /usr/spool/mail/$user)
  708. set msgs=(10 /usr/msgs/bounds)
  709. set history = 50
  710.  
  711. source  ~/.aliases
  712. set D = /net/dagobah/u0/mike
  713. set d = /net/dim/u0/mike
  714. set k = /net/kessel/u0/mike
  715. set n = /net/nellybell/u0/mike
  716. if (! $?HOST) setenv HOST `hostname`
  717. alias s_prompt 'set prompt = "[$HOST\\\!$cwd]\\
  718. % "'
  719. alias cd 'cd \!*; s_prompt'
  720. s_prompt
  721.  
  722.  
  723. ::::::::::::::
  724. cshrc/5
  725. ::::::::::::::
  726. From: sun!dagobah!mike
  727. Date: Mon, 17 Sep 84 23:27:19 pdt
  728. To: sun!resonex!nancy
  729. Subject: .aliases
  730.  
  731. alias alice    cu -s 1200 2016654115
  732. alias rabbit    cu -s 1200 2016654150
  733. alias yale    cu -s 1200 2034323510
  734. alias ajax    cu -s 1200 2015828265
  735.  
  736. alias ts     'setenv TERM `tset - \!* -Q`;set term = $TERM;unsetenv TERMCAP;'
  737. alias aa    "ts aaa-26; aaapf"
  738. alias aaa    aa
  739.  
  740. alias h        history
  741. alias l        'ls -Fa'
  742. alias lp    l -t
  743. alias ll    'ls -laF | more'
  744. alias wo    /u0/td/bin/who
  745. alias m        'make \!* >>& errors &'
  746. alias mail    Mail
  747. alias ml    /bin/mail
  748. alias lm    ml
  749. alias rml    'rm -f /usr/spool/mail/mike'
  750. alias RM    '/bin/rm -rf'
  751. alias clean    'rm *.o core errors a.out'
  752. alias CLEAN    'RM *.o core errors a.out ~/.REMOVED; mkdir ~/.REMOVED'
  753. alias die    'clear; kill -HUP $$'
  754. alias tlog    tail -f /usr/spool/uucp/LOGFILE
  755. alias ter    tail -f errors
  756.  
  757.   #
  758.   # For job control:
  759.   # Use 'fg' to bring job into the foreground, 'bg' to run job in background.
  760.   #   'v', to restart vi editor
  761.   #   'W', to restart ice editor
  762.   #   'j', to list out jobs
  763.   #   'k', to kill jobs; 'k 2' kills job [2]; 'k' kills the most recent job (+).
  764. alias v       %vi
  765. alias j       jobs
  766. alias k       'kill %\!*'
  767. alias sysline ~/bin/sysline -Dhmrj
  768.  
  769.  
  770. ::::::::::::::
  771. cshrc/6
  772. ::::::::::::::
  773. Date: Fri, 21 Sep 84 01:17:43 cdt
  774. From: ihnp4!uiucdcs!liberte (Daniel LaLiberte)
  775. To: sun!resonex!nancy
  776. Subject: .cshrc trick
  777.     
  778. I like my recursive prompt that shows the depth of shell calls with added
  779. ">"s.  It also gives a different prompt for my superuser which has the same
  780. home.  Additionally, we have several vaxes, uiucdcs*, networked with
  781. ethernet.  Upgrades are easier with the same .cshrc on all machines.
  782.     
  783.     
  784. ...
  785. if (! $?PROMPT) setenv PROMPT ""    # initialize
  786. setenv PROMPT "$PROMPT>"        # add ">"
  787. if ($?prompt) then
  788.     set sys = `hostname`
  789.     if ("$prompt" == "% ") then    # regular user
  790.         set prompt = `echo $sys | sed s/uiucdcs//`
  791.     else if ("$prompt" == "# ") then    # super user
  792.         set prompt = "$sys#"
  793.     endif
  794.     set prompt = "$prompt\!$PROMPT "
  795. endif
  796.     
  797.     
  798. My login prompt (on uiucdcs) is:
  799.     
  800. 1>
  801.  
  802. A csh call will produce:
  803.     
  804. 1>>
  805.     
  806. Remote login to uiucdcsb, for example:
  807.     
  808. b1>
  809.     
  810. Superuser on uiucdcsb:
  811.     
  812. uiucdcsb#1>>
  813.     
  814.     
  815. I have an alarm script and a spooled rcp that both use `at`.
  816.  
  817. Daniel LaLiberte
  818. ihnp4!uiucdcs!liberte
  819.  
  820.  
  821. ::::::::::::::
  822. cshrc/7
  823. ::::::::::::::
  824. Date: Sun, 7 Oct 84 20:35:02 pdt
  825. From: Ken Greer <hplabs!kg>
  826. To: resonex!nancy
  827. Subject: Xmas is early this year...
  828.  
  829. Here's what I thought were the most interesting things in my 
  830. csh profile.
  831.  
  832. 1. Prompt is (curdir hist#), or [curdir hist#] if running as su.
  833.    The brackets stack, so if I login as kg and su to kgsu, my prompt
  834.    is [(curdir hist#)] indicating my previous shell was non-su.
  835.    In both cases, the current directory always appears in prompt.
  836.  
  837. 2. On that subject, I heartily recommend a separate su login
  838.    for each su-er on a system.  This lets everyone have their
  839.    own profile, and when they quit you don't have to change the su passwd,
  840.    just remove their su.
  841.  
  842. 3. The directory stuff. (I prefer it to pushd/popd.)
  843.    ds   - displays directory stack (set to length DSSIZE below).
  844.    go # - go to directory item number #
  845.    back - go to previous directory.
  846.    cd   - stack current directory and go to a new one.  Oldest directories
  847.       fall off end of stack (whose size is DSSIZE).
  848.  
  849. 4. The "e" and "ec" commands let you edit the last or any command.
  850.    If works with a special program.  Would you like that?
  851.  
  852. 5. Delete/Undelete - special program.  Lets you recover deleted
  853.    files up to three days (user selectable).
  854.  
  855. 6. Do you know about my tcsh?  Not sure how it fits in with tricks though.
  856.  
  857.                 -Ken
  858.  
  859.  
  860. # Fancy prompt...
  861. if ($?prompt) then
  862. if (! $?LEFTPROMPT) setenv LEFTPROMPT ""
  863. if (! $?RIGHTPROMPT) setenv RIGHTPROMPT ""
  864. if (`whoami` == root) then
  865.     setenv LEFTPROMPT '['"$LEFTPROMPT"
  866.     setenv RIGHTPROMPT "$RIGHTPROMPT"']'
  867.    set path=(~/bin /usr/local/etc /etc /usr/local/bin /usr/ucb /bin /usr/bin .)
  868. else
  869.     setenv LEFTPROMPT '('"$LEFTPROMPT"
  870.     setenv RIGHTPROMPT "$RIGHTPROMPT"')'
  871.     set path=(~/bin /usr/local/bin /usr/ucb /bin /usr/bin .)
  872. endif
  873. alias setprompt 'set prompt = "${LEFTPROMPT}${cwd} \\!${RIGHTPROMPT} "'
  874. setprompt
  875. alias a    alias
  876.  
  877. # directory manipulation...
  878. set DSSIZE = 10
  879. if (! $?DS) set DS = (~)
  880. a back    'set xx=$DS[$#DS] DS[$#DS]=$cwd; chdir $xx; unset xx; setprompt'
  881. a go    'set xx=$DS[\!*] DS[\!*]=$cwd; chdir $xx; unset xx; setprompt'
  882. a ds    'echo $DS | tr " " "\012" | cat -n'
  883. a cd   'if ($#DS >= $DSSIZE) shift DS; set DS = ($DS $cwd);chdir \!*; setprompt'
  884.  
  885. # virtual remove...
  886. a rm    del
  887. a rm!    /bin/rm
  888.  
  889. # edit command...
  890. a e    '/usr/local/bin/ec \!-1:q'
  891. a ec    '/usr/local/bin/ec "\!*:q"'
  892.  
  893. # misc...
  894. a j    jobs
  895. a ls    '/usr/ucb/ls -F'
  896. a tag    '/usr/ucb/vi -ta \!*'
  897. a ts    'set noglob;eval `tset -s -Q \!*`'
  898. a wd    'echo $cwd'
  899. endif
  900.  
  901.  
  902. ::::::::::::::
  903. cshrc/8
  904. ::::::::::::::
  905. Date: Thu, 13 Sep 84 08:36:47 edt
  906. From: sun!decvax!genrad!teddy!dls (Diana L. Syriac)
  907. To: genrad!decvax!decwrl!sun!idi!resonex!nancy
  908. Subject: Re: Tricks, shell and awk scripts, csh aliases and the like
  909.  
  910. I'm sorry, I don't really have any "tricks" to make life easier, I'm also
  911. a rather new Unix user....except for one:
  912.     I use setenv a lot to define a bunch of directories that I use
  913.     a lot.  For example, I have in my .cshrc:
  914.         setenv obc ~doc/rts/obc
  915.     So anytime I want to get to that directory (or just look at it), I
  916.     just type:    ls $obc/filename
  917.     These environment variables work inside of mail as well as inside of
  918.     emacs.
  919. I suppose you already have that one from other people.
  920.  
  921. We also have on our system some "local" programs that make life a lot easier:
  922. We have an "lf" and "dir" that replaces "ls" and "ls -l", but with an added
  923. feature:  directories are displayed in bold letter, executables are displayed
  924. in reverse video and special files are displayed in flashing letters.  It's
  925. quite easy to see at a glance what the files are or where you want to go.
  926.  
  927. We also have a "pushd" and "popd" which replace the "cd" command.  
  928.     pushd directory
  929. will pushd a directory onto the "stack", and change to it.  After you're
  930. finished with that directory, just typing
  931.     popd
  932. will put you back to where you were.  There is a "dirs" command to 
  933. allow you to look at the "stack" to see where you are, where you've been.
  934. If you use "cd" instead, it's smart enough to change your stack and replace
  935. the current directory with the one specified in "cd". And if you just say
  936. "pushd" by itself, it will SWAP the current directory with the last directory
  937. you were in, making it very easy to toggle between two directories.
  938.  
  939. Other things that we've done:
  940.     Built a script for the nroff command that is used by most people
  941. on the system, including macros and some "local" filters to make it look
  942. nice on terminal, line printer, and diablo.  I have also created a little
  943. program which can be used in conjunction with nroff to produce "change bars"
  944. at the left margin of documents.  We used the change bars quite a lot under
  945. vms rno.
  946.     We have a set of programs that produce "C" listings, with a table
  947. of contents showing all files AND routines, page numbered and file numbered,
  948. each file has a line number at left margin indicating file and line number
  949. (eg: 3.41 refers to file 3, line 41), and at the very end of listing, there
  950. is a cross-reference of all tokens, giving file.line references.  Part of
  951. this set of programs was taken directly off the net and modified for our
  952. own use.
  953.  
  954. Well, that's all that I can think of for now.  BUT what I really mailed
  955. to you was for something that I want.  At the last DECUS, one of the speakers
  956. demonstrated a little program that he wrote that allowed him to keep a
  957. running log of what he did every day.  The program started up when he logged
  958. on, and ran in the background.  Every 15 minutes, it would beep at him,
  959. asking him to input a line telling what he was currently doing.  If ignored,
  960. it would beep at him every minute until he input something to it.  I don't
  961. know who the guy was, and I lost his business card, but I'd sure like to
  962. get that program if you have it.  Thanks much.
  963.  
  964.             Diana L. Syriac
  965.             GenRad, Concord, Ma.
  966.             decvax!genrad!teddy!dls
  967.  
  968.  
  969. ::::::::::::::
  970. logins/1
  971. ::::::::::::::
  972. From: sun!dagobah!mike
  973. Date: Mon, 17 Sep 84 23:26:53 pdt
  974. To: sun!resonex!nancy
  975. Subject: .login
  976.  
  977. #tset -m dialup:aaa-60 -Q
  978. tset -m dialup:c100-4p -Q
  979. setenv TERM $term
  980. switch ($TERM)
  981.     case dialup:
  982.         set term = aaa-60; setenv TERM $term
  983.         ~/bin/aaapf
  984.         breaksw
  985.     case c100-4:
  986.     case c108-4p:
  987.         sysline
  988.     case c100-4p:
  989.         setkeys
  990. endsw
  991. stty new erase "^?"
  992.  
  993. biff y
  994. setenv notify true
  995. setenv CWD $cwd
  996. setenv SHELL /bin/csh
  997. setenv MAIL ~/Mail
  998. setenv MANPATH /u0/pn/man:/u0/mike/Man:/usr/lfl/man:/usr/man
  999. setenv INCPATH /usr/lfl/include:/usr/include:/u0/mike/Include
  1000. setenv LIBPATH /usr/lfl/lib:/lib:/usr/lib:/u0/mike/Lib
  1001. setenv LOADPATH /usr/src/lfl/bin/emacs.unipress/emacs4.2/maclib
  1002. setenv EDITOR /usr/ucb/vi
  1003. uupoll ucbvax
  1004. msgs
  1005.  
  1006.  
  1007. ::::::::::::::
  1008. logins/2
  1009. ::::::::::::::
  1010. Date: Fri, 14 Sep 84 10:42:43 edt
  1011. From: Jay Weber  <amd!mordor!ut-sally!seismo!rochester!jay>
  1012. To: ut-sally!mordor!dual!amd!resonex!nancy
  1013. Subject: Re: Tricks, shell and awk scripts, csh aliases and the like
  1014.  
  1015. I use the hold option in my .mailrc, which keeps messages around
  1016. until you explicitly delete them.  That's a popular option since
  1017. it makes it easy to keep around descriptions of things to do, but
  1018. it gets hard to tell when you have new mail and how much.  So, I
  1019. have this in my .login:
  1020.  
  1021. @ newmail= `from $mail[$#mail] |awk 'END{print NR}'` - `cat .mailsize`
  1022. if ($newmail == 1) then
  1023.   echo "(There is one new mail message.)"
  1024. else
  1025.   if ($newmail > 1) echo "(There are $newmail new mail messages.)"
  1026. endif
  1027. ------------
  1028. and this in my .logout:
  1029.  
  1030. if (-r $mail[$#mail]) then
  1031.   from $mail[$#mail] | awk 'END{print NR}' >~/.mailsize
  1032. endif
  1033. ------------
  1034.  
  1035. Jay Weber
  1036. ..!seismo!rochester!jay
  1037. jay@rochester.arpa
  1038.  
  1039.  
  1040. ::::::::::::::
  1041. logins/3
  1042. ::::::::::::::
  1043. Date: Fri, 14 Sep 84 15:16:00 cdt
  1044. To: ctvax!convex!allegra!resonex!nancy
  1045. From: allegra!convex!trsvax!gm  (George Moore)
  1046. Subject: neat .login's
  1047.  
  1048. Nancy,
  1049.    Here is some of the aliases I use, as well as part of my .login
  1050. file: (We are running 4.1BSD on a 11/780)
  1051.  
  1052.   alias back 'set back=$old; set old=$cwd; cd $back; unset back'
  1053.   alias cd 'set old=$cwd; chdir \!*; sp'
  1054.   alias sp 'set prompt="$cwd> "'
  1055. Those aliases allow my prompt to always be my current directory.
  1056. You never have to run "pwd" again. Looks kindof strange when you
  1057. are in a low directory like /g/usr/src/local/csh, but you get used
  1058. to it. It also allows you to cd to some low dir, and then type
  1059. "back" and you are back in the directory you started in.  
  1060.  
  1061. I have this line in my .login:
  1062.   sh -c "$HOME/bin/firstlog &"
  1063. This line allows you to spin off a background job without the
  1064. "[1] 22934"  message messing up your screen. Firstlog is done
  1065. below. I have a security program which goes out and checks a few
  1066. key files and directories (/etc/passwd, /etc/group, /usr/lib/crontab,
  1067. /etc). If anything has changed, it sends me mail informing me of the
  1068. fact. But I only wish it run once a day, at the time I first login for
  1069. the day. (I don't want it run from crontab, that makes things too
  1070. predictable for the users)
  1071.  
  1072. ---------------------------------------------------------------------
  1073. #! /bin/csh
  1074. #  Firstlog -- finds out if this is the first time I have logged in 
  1075. #              today and start-up all sorts of neat stuff if it is.
  1076.  
  1077. set date=`/bin/date`
  1078. set now=`/usr/ucb/last $user`
  1079. if ($date[2] != $now[13] || $date[3] != $now[14]) then
  1080.     sh -c "$HOME/personal/security/secure &"
  1081. endif
  1082. ---------------------------------------------------------------------
  1083.  
  1084. I hope this helps.                George Moore
  1085.                         gm@trsvax.UUCP
  1086.