home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / x / volume13 / xcal / part02 / scott_brim / vixc.csh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1991-05-12  |  687b  |  30 lines

  1. #!/bin/csh
  2. #
  3. # edit with vi an xcal daily diary file, with date defaulting to today.
  4. # From: Scott Brim <swb@chumley.tn.cornell.edu>
  5.  
  6. # constants
  7. set months = \
  8. {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}
  9.  
  10. # default to today
  11. set thedate = `date +%m/%d/%y`
  12. if ($1 != "") set thedate = $1
  13.  
  14. set month =    `echo $thedate | cut -d/ -f1`
  15. set monthname = $months[$month]
  16. set day =    `echo $thedate | cut -d/ -f2`
  17. set year =    `echo $thedate | cut -d/ -f3`
  18. if ( $year < 100 ) @ year = $year + 1900
  19.  
  20. # build filename
  21. set filename = "~/Calendar/xy"${year}"/xc"${day}${monthname}${year}
  22.  
  23. if ($?VISUAL) then
  24.     $VISUAL $filename
  25. else
  26.     /usr/ucb/vi $filename
  27. endif
  28.  
  29. exit $status
  30.