From: Nancy Blachman To: net.unix, net.unix-wizards, net.sources Subject: Actual tricks, shells, csh aliases and the like, 1 of 3 Date: 16 Oct 84 21:20:53 GMT Organization: Resonex Inc., Sunnyvale, CA > [Know anybody with a GREAT .login or .cshrc?] > I'm interested in collecting the little tricks, shell scripts, awk > hacks, csh aliases, and such that people have built to make their daily > life a little easier or more automatic. Being a fairly new system > administrator I don't have the big toolbox that years of messing around > will leave you with. If you have any hacks you're proud of (or that > you aren't proud of, but which work anyway), and you're willing to make > them public, mail them to me. I'll collect, collate, shuffle, sort, > munge, judge, select and discard them and then "summarize to the net". This article concentrates on aliases, and .cshrc and .login files I received in response to my solicitation. The second article in this series focuses shell scripts. The third article centers on C programs and awk scripts. /\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\/ > Nancy Blachman {allegra,hplabs,ihnp4,sun}!resonex!nancy (408)720 8600 x37 < /\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\/ :::::::::::::: aliases/1 :::::::::::::: Date: Thu, 13 Sep 84 07:27:35 est From: ihnp4!pur-ee!davy (Dave Curry) To: ihnp4!resonex!nancy Subject: aliases Nancy: Here's a few handy aliases to put your current working directory into your prompt: alias cd chdir \!:\* \; set prompt='${cwd}\[!\]\ ' \; setenv CWD '$cwd' alias pd pushd \!:\* \; set prompt='${cwd}\[!\]\ ' \; setenv CWD '$cwd' alias pp popd \!:\* \; set prompt='${cwd}\[!\]\ ' \; setenv CWD '$cwd' These put the current directory into the environment also, this is for an editor used here locally which uses this information. You can delete that part if you don't need it. --Dave Curry ihnp4!pur-ee!davy :::::::::::::: aliases/2 :::::::::::::: From: hplabs!sdcrdcf!sdcsvax!greg (Greg Noel) Date: Thu, 13 Sep 84 10:57:51 pdt Return-Address: ucbvax!sdcsvax!greg or Greg@NOSC Organization: NCR Corporation, Torrey Pines To: sdcrdcf!hplabs!resonex!nancy Subject: Re: Tricks, shell and awk scripts, csh aliases and the like I have three little gems from my bag of tricks that I'd like to show you, all for the C shell. The first is an alias for the `pwd' command: alias pwd echo \$cwd The built-in variable `cwd' always contains the current working directory, and since `echo' is a built-in command, this is MUCH faster than invoking a program to calculate the actual location. The only problem (and I don't have a solution) is that it gets confused by symbolic links to directories. The second one is something that turns the directory structure from something passive into something active: alias come if -e .greg_come source .greg_come alias go if -e .greg_go source .greg_go alias cd go \; set prev = \$cwd \; chdir \!\* \; \ echo \$prev ==\\\> \$cwd \; come What this does is cause the shell to look for a specific file whenever it transfers into a directory, and if it is there, source it. Also, whenever you leave a directory, it looks for a different file and sources that before leaving. I use this to set up location-specific aliases or to have something happen auto-magicly whenever I work in some diretory -- for example, changing into my `play' directory invokes a menu that will set up the environment and run game programs -- different save files for `rogue' or other stuff that I don't want to carry around with me all the time. It's more flexible than it seems at first glance; the only thing I can suggest is to try it and you will keep finding new ways to use it. The last one is really a replacement for the `pushd' and `popd' commands -- I didn't like the way they worked, so I did these. It seperates the action of pushing a directory from the action of changing directories. I wanted this since I also have a whole bunch of aliases to move between widely- seperated portions of the filesystem (something I do a lot) and it was easier for me to type `push; u test' (which pushes the current directory and takes me into the `test' subdirectory of something interesting) than to type `pushd /long/complicated/path/test'. This isn't terribly original, but the gem, and something I find VERY useful is the `back' command, which takes you to the directory you last left, so you can bouce back and forth between two directories -- one is the source location and one the test location, for example. Anyway, here's what it looks like: alias push set dirstack = \( \$cwd \$dirstack \) \; \ echo Pushing \\\[\$\#dirstack] \$cwd \; \!\* alias pop cd \$dirstack\[1] \; set dirstack = \( \$dirstack\[2-] \) alias back set dirstack = \( \$prev \$dirstack \) \; pop alias pp set x = \$dirstack\[1] dirstack\[1] = \$cwd \; cd \$x Notice that it interacts with the previous alias for `cd' in that it expects the variable `prev' to have the previous directory (which is what `cd' leaves in it). The `pp' alias is sometimes useful -- it pushes the current directory while transfering to the old top of stack, a simultaneous push-pop. I hope you found these interesting and entertaining. -- Greg Noel, NCR Torrey Pines Greg@sdcsvax.UUCP or Greg@nosc.ARPA :::::::::::::: cshrc/1 :::::::::::::: From: Date: Thursday, 13 Sep 84 09:48:55 PDT To: resonex!nancy, jerryp Subject: Re: Tricks, shell and awk scripts, csh aliases and the like Nancy, I'll mail you a few .cshrc and .login files. Unfortunately, I'm short on time... so I can't comment a lot... but I'd be glad to answer any questions you've got about how they work. A summary of them: 1) This .cshrc file comes from the tektronix!tekred machine in Redmond, Oregon. Its neat feature is that, when a user "su"'s to someone else's account, their prompt changes from % to account> where the "su"'d name appears before the >. Very nice, I think. Also, they do a standard thing around here. The first line [if ($?prompt)] checks to see if the .cshrc is being scanned by an interactive shell. If so, the commands below are executed. If not (like a shell escape from "vi"), the commands aren't executed. This really speeds up shell escapes! (I do the same thing, in a different way, in my .cshrc file.) 2) This is my .login file. I should mention that I've got my own calendar system that's updated every morning at 1 AM by "at". It sits in my ".calendar" directory. You'll see a lot of that stuff in the .login file. 3 & 4) I have *two* .cshrc files. One, ".cshrc", is the standard file. It contains a limited list of aliases and setup commands. The other, ".cshrc2", is one I source when I'll be logged on for a long time and doing a lot of work. The .cshrc2 has time-saving aliases like "alias m more" in it. At login, the .cshrc is always read. This sets my prompt to something like where # is the C-shell history number. Also, since my system is so busy, I have a "quick login" setup in .cshrc to let me see my mail immediately and logout without doing anything else, if I want to. This quick-login has a $ prompt set... the Bourne-shell prompt. If I want an extended login, I execute the alias "res" (from .cshrc). It sets alarms automatically (for meetings, etc... from my .calendar directory) and re-sets my prompt to something like [directory,#] That way, I know that I've got all my aliases available. Since my system is overloaded, this dual-.cshrc system saves me time and hassle... .cshrc2 takes a long time to source. --Jerry Peek, UNIX Training Instructor, Tektronix, Inc. US Mail: MS 76-036, P.O. Box 500, Beaverton, OR 97077 uucp: {allegra,decvax,hplabs,ihnp4,mit-eddie,ucbvax}!tektronix!jerryp CSnet: jerryp@tek ARPAnet: jerryp.tek@csnet-relay Phone: 503/627-1603 --------------------------------------------------------------------------- FILE #1 (.cshrc): if ($?prompt) then set history=20 set path=(. $home/bin /usr/local /usr/tek /usr/public /usr/ucb /bin /usr/bin) set mail=(300 /usr/spool/mail/$home:t /etc/motd) source ~/.aliases set prompt=`whoami | sed -e 's/ .*//' -e 's/user=//'` if ($prompt == $user || $prompt == "") then set prompt="% " else set prompt="$prompt> " endif endif --------------------------------------------------------------------------- FILE #2 (.login): uptime # show system load set ignoreeof # do not logout on EOF (^D) set noclobber # do not overwrite files with > or >> cp ~/.exrc8 ~/.exrc # set up vi/ex to environment in ~/.exrc8 setenv EDIT /usr/ucb/vi # set default editor to vi setenv PRINTER uph # if type "man -Tlpr", use "uph" to store for printing setenv NEWSBOX ~ # save news (readnews "s") in home directory or beneath set noglob; eval `tset -srQm 'plugboard:?4025'`; unset noglob stty new crt # new tty driver, crt terminal, see newtty(4) stty tostop hup # stop background jobs on output, hangup hw on logout limit filesize 2000 # do not write file > 2,000,000 bytes limit coredumpsize 0 # prevent core dumps when csh bombs touch .llog # set correct last login time for finger if ($TERM == 'tek4023' || $TERM =~ aaa*inv ) then # KEEP more FROM USING THE ul OPTION AND MESSING UP DISPLAY: setenv MORE -u else if (($TERM == qume5) || ($TERM == dumb)) then mesg n exit 0 endif # immediate notification (every 60 seconds) of mail: set mail = (60 /usr/spool/mail/$user /etc/motd) # check /etc/motd for changes; if any, show them and (maybe) add to calendar: diff ~/.calendar/last.motd /etc/motd >! /tmp/motd.diff if ( $status != 0 ) then echo "< = old MOTD ... > = new MOTD" more /tmp/motd.diff echo "To read the new MOTD into the calendar, answer y. To ignore it, answer q." echo -n "Otherwise, hit RETURN: " set ans = $< if ($ans == "y") then cat /etc/motd | tee -a ~/.calendar/calendar >! ~/.calendar/last.motd vi + ~/.calendar/calendar echo "To reset *today's* calendars, type 'calendar.set -F'." else if ($ans == "q") then cat /etc/motd >! ~/.calendar/last.motd endif endif echo "--------------------" inc # put new mail, if any, in ~/.mail/inbox echo "--------------------" set time = 10 # for jobs that take longer than 10, show how long # IF THERE ARE LOGIN MESSAGES, SHOW THEM: if !(-z ~/.calendar/mesg.login) then echo "Here are the login messages, "`date '+%a %D'` echo "" doublespace ~/.calendar/mesg.login endif echo "For an uptime graph, type 'upgr'." --------------------------------------------------------------------------- FILE #3 (.cshrc): # if this is a non-interactive shell, quit. if ( ! $?prompt) exit 0 # save login system search path, removing leading "." (thanx to tekig!danr): if ( ! $?SYSPATH ) setenv SYSPATH "$path[2-]" # set default places to find commands (put current and .bin directories first): set path=(. ~/.bin $SYSPATH /usr/public{,/texthelp} /usr3/{barbaraz/.,tcomm/}bin) # CHECK FOR QUICK LOGIN: if (! $?LOGGEDIN) then echo -n "For quick login (Bourne shell), answer y; otherwise, press RETURN: " if ( "$<" =~ y* ) then echo "To continue with login, press control-D; to logout, type 'stty 0'" /bin/sh -i echo "Continuing with standard login..." endif endif setenv LOGGEDIN x # set cd search path for directory names which aren't sub-directories: set cdpath=(~ `finddirs ~/training{,/*} /usr3/tcomm/unix{,/*}` ~/.bin ~/.log ~/.mail ~/stuff ~/tape*) set history=1000 # keep the last 1000 commands in history # use /usr/public/prompt to get massaged directory name for prompt-setting: set prompt = "<`prompt ~ $cwd`,"{\!}"> " # edit my calendar: alias calen 'vi ~/.calendar/calendar; echo '"To reset today\'s calendars, type calendar.set -F"'' # change directory, reset prompt: alias cd 'chdir \!*; set prompt = "<`prompt ~ $cwd`,"{\!}"> "' # add to specified .log directory alias log 'echo "Put a .ze at end of file, unless last log of this set.";vi + ~/.log/`cat ~/.log/latestlog`/\!*' # create newterm command to allow terminal-type change alias newterm 'set noglob;eval `tset -srQ \!*`;unset noglob' # sets alarms (if any) and sources '.cshrc2' (my other alias list) alias res '~/.bin/alarm.set ; source ~/.cshrc2' alias todo 'vi ~/todo\!*' # change one of the "to do" lists --------------------------------------------------------------------------- FILE #4 (.cshrc2): # notify immediately when background jobs are finished set notify # prompt with current directory name, history number: alias s_p 'set prompt = "[`prompt ~ $cwd`,"{\!}"] "' s_p # set 'vi' for 4-character tabs/shifts: alias 4vi 'cp ~/.exrc{4,}; echo "MODE: programming"' # set 'vi' for 8-character tabs/shifts: alias 8vi 'cp ~/.exrc{8,}; echo "MODE: text"' # set 'vi' for quick work (no .exrc file): alias qvi 'rm ~/.exrc; echo "MODE: quick"' # easy way to compile "C" programs (ring bell if filename ends with ".c"): alias C 'if ("\!*" =~ *.c) yes ;mv \!* ,\!*;echo \!*.c" SENT TO cc";cc \!*.c -o \!*;if (-e \!*) chmod 311 \!*' # show alarms that (may be) set... and message explaining them: alias alarms 'echo "These alarms have been set:";cat ~/.calendar/mesg.alarm; \ps | fgrep ".bin/nleave"' # change back to previous directory: alias c- 'set x=$cwd; chdir $lastdir; s_p; set lastdir=$x' # edit my calendar: alias calen 'v8 ~/.calendar/calendar; echo '"To reset today\'s calendars, type calendar.set -F"'' # see today's calendars: alias cals 'cat ~/.calendar/mesg.*' # save current directory for 'c-', change directory, reset prompt: alias cd 'set lastdir=$cwd; chdir \!*; s_p' # see mail without inc'ing it: alias checkm 'see /usr/spool/mail/jerryp' # same as 'cd', but lists directory, too: alias cl 'set lastdir=$cwd; chdir \!*; ls -F; s_p' # same as 'cl', but gives long list: alias cll 'set lastdir=$cwd; chdir \!*; ls -l; s_p' alias f 'grep "^\!*" /etc/passwd' # quick version of "finger -s" alias H 'history -r | fgrep "\!*"' # find something in history list alias h history 5 # show last five lines alias hi history 10 # show last ten lines alias his history 20 # show last twenty lines alias hist 'history 40|m' # show last forty lines; pipe to 'more' alias histo 'history 70|m' # show last seventy lines; pipe to 'more' # send output of command to 'pr' (with command as header), then to uph: alias hpr '\!* | pr -h "\!*" | uph' alias j 'jobs -l >! /tmp/j$$; pushin /tmp/j$$; rm /tmp/j$$' # show job status (process numbers, too) squeezed onto one line each alias lc 'ls *.c' # list all C source code in this directory # add to specified .log directory alias log 'echo "Put a .ze at end of file, unless last log of this set.";v8 + ~/.log/`cat ~/.log/latestlog`/\!*' # list executable files, 5 columns, sorted across 80-wide line: alias lx 'lf -1 | fgrep \* | pr -t -5 -l1 -w80' alias m more # shortened form of 'more' command # faster pwd (singlequotes prevent expansion before it's executed): alias pwd 'echo $cwd' # re-start inverse video on Ann Arbors: alias reinv 'echo "[7m";clear' # lock terminal until ^C and login password are entered: alias somb /usr3/jos/bin/somb alias showm 'inc;show' # get new mail # give more info (how much time I've used) when using "status": alias status 'source ~/.bin/status' alias tcpr 'tcprint -p12 -m5 -ff \!* &' # typical quick "tcprint" use alias todo 'v8 ~/todo\!*' # change one of the "to do" lists alias up uptime # make uptime graph: alias upgr '(nohup uptime_graph ~/,up`date +%m%d.%H%M` &)' # show uptime today's graph: alias upsh 'uptime_show -20 ~/,up`date +%m%d`*' # 'vi' for programming: alias v4 '4vi;vi \!*' # 'vi' for standard text: alias v8 '8vi;vi \!*' # call 'vi' with a search (must use 8vi because search requires a 'wrapscan') alias vs '8vi; vi +/\!*' alias write '/usr4/danr/bin/rite -c \!*' # show each character as it's typed #UNUSED ALIASES: #alias cd 'set lastdir=$cwd;chdir \!*;set prompt="`~/.bin/prompt`"' # change to maps directory: #alias maps 'cd /usr/spool/news/lib/maps;echo "switching to newsa";su newsa;set $user=jerryp;c-' # keep "at" job from dying because of long EXINIT: #alias niterun 'setenv EXINIT "set sw=8";\niterun \!*;8vi' #alias du ~danr/bin/du # improved version of "directory usage" query # format text, save in file".ty", then show it on the crt: #alias typeup '~/.bin/type \!* >! \!*:r; more \!*:r' # give description of 'ps' codes before doing the 'ps': #alias ps 'cat ~/.ps.man;\ps \!*' # easy way to compile and run "C" programs # (ring bell if filename ends with ".c"): #alias c 'if ("\!*" =~ *.c) yes ;mv \!* ,\!*;echo \!*.c" SENT TO cc";cc \!*.c -o \!*;echo "press ^C to stop execution";sleep 2;./\!*' # easy way to change editor environment files: #alias adde 'vi ~/.exrc\!*; set ex=(`cat ~/.exrc\!*`); setenv EXINIT "$ex"' #alias rmm '\rmm \!* &' # remove mail in background # faster "man" listings: #alias man 'echo "man -q:"; \man -q \!*' # improved spell routine (write-protected dictionary): #alias spel 'chmod +w ~/.misspell; /usr/public/spel \!*;chmod -w ~/.misspell' # show whether using ~/.exrc4 or ~/.exrc8: #alias vi 'echo "MODE: "$EXSTAT;/usr/ucb/vi \!*' #alias comp '8vi;\comp \!*' # set 'vi' for text before doing the 'comp' # show last ten users of "tcprint" program: #alias tcp tail /usr3/tcomm/.tcprint/log # favorite "ps" (gives PID, PPID, STAT, TT, TIME, and long description): #alias p 'ps lwx | cut -c12-22,53- | nfold' :::::::::::::: cshrc/2 :::::::::::::: Date: Thu, 13 Sep 84 02:16:31 edt From: ihnp4!seismo!umcp-cs!chris (Chris Torek) To: ihnp4!resonex!nancy Subject: Re: Tricks, shell and awk scripts, ... Actually Re: [Know anybody with a GREAT .login or .cshrc?]: I don't know about *great*, but I'm probably one of the candidates for *slowest* . . . . FYA (For Your Amusement), here's my .login and .cshrc on this machine (they're not the same on tove, gyre, gymble, and eneevax). Chris : Run this shell script with "sh" not "csh" PATH=:/bin:/usr/bin:/usr/ucb export PATH all=FALSE if [ $1x = -ax ]; then all=TRUE fi /bin/echo 'Extracting .cshrc' sed 's/^X//' <<'//go.sysin dd *' >.cshrc # if ($?prompt) then echo -n '[' set path=(. ~chris/bin ~chris/sys /usr/local/bin /g/local /usr/ucb /bin /usr/bin /usr/games /etc /usr/hosts) echo -n 'cshrc]' 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 alias hh history;alias h 'history 20';alias j jobs;alias o popd alias status 'echo $status';alias so source;alias bye logout alias p pushd;alias done 'echo ';alias kb "rm -i .*.bak *.bak .*.CKP *.CKP" alias kc "rm -i .*.CKP *.CKP";alias e emacs;alias @@term 'kill -9 $$' alias af ~chris/af/af;alias cdl "cd \!:1;ls \!:2*";alias lsl "ls -li" alias lsa "ls -A";alias lsla "ls -lai";alias up "cd ..";alias upl "cd ..;ls" alias cdll "cd \!:1;lsl \!:2*";alias lsld "lsl -d";alias lslg "lsl -g" alias upll "cd ..;lsl";alias pl "pushd \!:1;ls \!:2*";alias z logout alias pll "pushd \!:1;lsl \!:2*";alias ol "popd;ls";alias oll "popd;lsl" alias cdla "cd \!:1;lsla \!:2*";alias v80 'echo -n "[?2l";set term=VT52' alias v132 'echo -n "[?2l";set term=VT52.132';alias ansi 'echo -n "<"' alias fix 'stty newcrt erase  kill ';alias ca 'ex "+1,.|q"' alias own 'cp \!:1 /tmp/own$$;rm -f \!:1;mv /tmp/own$$ \!:1' alias save 'cp \!:1 \!:1.old;chmod a-w \!:1.old;chmod +w \!:1' alias c80 'echo -n "[?3l";set term=DT80';alias suspend 'suspend;dirs' alias col80 'echo -n "[?3l";colnum 80';alias a alias alias c132 'echo -n "[?3h";set term=DT80.132' alias col132 'echo -n "[?3h";colnum 132' alias hold 'echo -n "[H[J[12;20H[5mI'"'"'ll be right back[m[20H";lock;echo -n "[H[J"' alias feed '(sleep 3000;echo Feeding time\\!)&' alias open 'set noglob;eval `/usr/chris/bin/open \!:*`;unset noglob' alias loav /usr/mark/bin/load setenv VISUAL /usr/ucb/vi;setenv EDITOR /usr/local/bin/emacs setenv EPATH :/usr/chris/emacs:/usr/israel/emacs:/usr/emacs/loclib:/usr/emacs/maclib alias dir ls;alias era rm;alias printman /usr/man/printman;alias d dirs alias clx 'rm -f /tmp/X_lock.\!:1 /usr/spool/uucp/LCK..\!:1' alias aasize 'set noglob;eval `/usr/local/bin/aasize \!:1`;unset noglob' alias aasave 'set noglob;eval `/usr/local/bin/aasave \!:1`;unset noglob' alias down 'cd `echo */|awk '\''{print $1}'\''`;echo $cwd' alias downl 'down;ls';alias downll 'down;lsl';alias mark 'set \!:1=$cwd' alias lso 'lsla | sort +4 -rn';alias edenv 'source ~chris/bin/edenv' alias aibib 'echo \!*|lookbib -n -p /usr/randy/papers/airefs|page' alias checkque /usr/lib/mmdf/checkque;alias sum-dial /usr/lib/mmdf/sum-dial alias deliver 'sh -c "HOME=/ /usr/lib/mmdf/deliver \!:*"' alias ll 'ls -l';alias tm 'telnet 128.8.0.8'; alias uptime endif umask 22 if ($?prompt) then set prompt='[\!] ' echo '' endif //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 .cshrc /bin/echo -n ' '; /bin/ls -ld .cshrc fi /bin/echo 'Extracting .login' sed 's/^X//' <<'//go.sysin dd *' >.login # stty erase ^H kill ^X intr decctlq nl0 cr0 ff0 cd;setenv TERMCAP /usr/chris/.termcap # cp .exrc1 .exrc # Set up the terminal # 4025=Tek4025 sd=dialup x1=Xer 1750 GG=Gigi d4=GT40 aaa=AAA else DT80 # if (`slowtty` == y) then # cp .mailrc2 .mailrc # else # cp .mailrc1 .mailrc # endif set wantbaud=0 top: switch ($TERM) case su: case network: set wantbaud=1 case sd: case unknown: set term=`/ful/chris/bin/selterm` goto top case 4025: stty crt tabs;tabset.tek breaksw case h6: case hp: case hp2623: case hp2626: stty tabs crt breaksw case v550: stty crt;set prompt='[7m[\!][m ' breaksw case GG: stty crt;unsetenv TERMCAP;set prompt='[7m[\!][m ' breaksw case d4: set term=gt40;stty crt breaksw case aaa: case aaa-60: set term=aaa prompt='[7m[\!][m ';stty tabs crt;unsetenv TERMCAP aakey -f /ful/chris/.aakeys if (`tty` =~ /dev/tty*) then echo -n 'Lines? [30] ' set lines=$< if ($lines != ) then aasize $lines endif endif breaksw case h19: case h19a: case kb: set term=h19a prompt='[7m[\!][m ';stty tabs crt crtkill breaksw case Dq: case DT80: case D5: case vt100: set term=DT80 prompt='[7m[\!][m ' echo -n '[?4l';stty crt breaksw default: unsetenv TERMCAP;echo "Wonder what $TERM is?" breaksw endsw if ($wantbaud == 1) then selbaud endif unset wantbaud lines # mailcount checknews setenv ROGUEOPTS 'jump,ask,terse,flush,passgo,fruit=hregfx' setenv PAGER /usr/ucb/page setenv SPELL_LISTS /ful/chris/.splist alias logout 'source /ful/chris/.logout.';alias exit logout # /usr/games/fortune w; # calend; /usr/chris/bin/ac 22:00 echo ---------------------------------------------------------- # rehist .history //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 .login /bin/echo -n ' '; /bin/ls -ld .login fi :::::::::::::: cshrc/3 :::::::::::::: Date: Fri, 14 Sep 84 14:59:01 pdt From: hplabs!sdcrdcf!sdcsvax!sdcc6!loral!hlb (Howard Brandell) To: sdcc6!sdcsvax!sdcrdcf!hplabs!resonex!nancy Subject: .cshrc I am sending my entire .cshrc file because I have some things in it that help me out. Firstly, note the aliases that allow me to selectively read those newsgroups of interest. Aha! You may say I can put it all in the .newsrc file and have the system inform me when there is news and read it out simultaneously. But, sometimes we get news during the course of the day and I like to check my favorites continuously. Also, not the aliases for tip. These allow me to dial my remote locations with both spped and accuracy. As an aside, I have created a .tiprc file which logs all my remote host conversation into a file. In this way, nothing is lost. Note the 'rt' command which allows me to purge tiplog. alias a alias a sd "msg,gju,glw,kay,sdi" a ds "chmod 600 .signature" a es "chmod 640 .signature" a vc "ccalc" a m "mail" a p "more" a rk "readnews -n net.kids" a ra "readnews -n net.micro.apple" a ri "readnews -n net.micro.pc" a rs "readnews -n sdnet.computing" a rb "readnews -n net.sport.baseball" a rn "readnews -n net.columbia" a rw "readnews -n net.wanted" a rl "readnews -n net.legal" a r "readnews" a logs "readnews -n net.sources -l>sources.log" a motd "cat /etc/motd|more" a h "history -r \!*|more" a t1 "tip 561-7271" a t2 "tip 452-1869" a t3 "tip 283-1538" a t4 "tip 692-1961" a t5 "tip 270-1166" a t6 "tip 217-1900" a rt "rm tiplog" a bye logout a cd "cd \!* ; dirs" a term 'set noglob; eval `tset -n -s \!*`' a wat "ps -au | more" a pv printenv a j "jobs -l" a f "finger|more" a l ls -F if ( $?prompt == 1 ) then set prompt="\!: " set mail=(60 /usr/spool/mail/$USER) endif set history = 24 set cdpath = (. ~) Also note the aliases for the more mundane commands, like mail and more -c. Hope this has been of some help. Please disregard my earlier transmission as I had some operational difficulties. Thx. :::::::::::::: cshrc/4 :::::::::::::: From: sun!dagobah!mike Date: Mon, 17 Sep 84 23:27:05 pdt To: sun!resonex!nancy Subject: .cshrc set mail=(10 /usr/spool/mail/$user) set path=(. ~/bin /usr/lfl/bin /usr/ucb /bin /usr/bin /usr/hosts /usr/suntool) set cdpath = ( . .. ~ /usr /u0 /u1 /audio) set mail=(10 /usr/spool/mail/$user) set msgs=(10 /usr/msgs/bounds) set history = 50 source ~/.aliases set D = /net/dagobah/u0/mike set d = /net/dim/u0/mike set k = /net/kessel/u0/mike set n = /net/nellybell/u0/mike if (! $?HOST) setenv HOST `hostname` alias s_prompt 'set prompt = "[$HOST\\\!$cwd]\\ % "' alias cd 'cd \!*; s_prompt' s_prompt :::::::::::::: cshrc/5 :::::::::::::: From: sun!dagobah!mike Date: Mon, 17 Sep 84 23:27:19 pdt To: sun!resonex!nancy Subject: .aliases alias alice cu -s 1200 2016654115 alias rabbit cu -s 1200 2016654150 alias yale cu -s 1200 2034323510 alias ajax cu -s 1200 2015828265 alias ts 'setenv TERM `tset - \!* -Q`;set term = $TERM;unsetenv TERMCAP;' alias aa "ts aaa-26; aaapf" alias aaa aa alias h history alias l 'ls -Fa' alias lp l -t alias ll 'ls -laF | more' alias wo /u0/td/bin/who alias m 'make \!* >>& errors &' alias mail Mail alias ml /bin/mail alias lm ml alias rml 'rm -f /usr/spool/mail/mike' alias RM '/bin/rm -rf' alias clean 'rm *.o core errors a.out' alias CLEAN 'RM *.o core errors a.out ~/.REMOVED; mkdir ~/.REMOVED' alias die 'clear; kill -HUP $$' alias tlog tail -f /usr/spool/uucp/LOGFILE alias ter tail -f errors # # For job control: # Use 'fg' to bring job into the foreground, 'bg' to run job in background. # 'v', to restart vi editor # 'W', to restart ice editor # 'j', to list out jobs # 'k', to kill jobs; 'k 2' kills job [2]; 'k' kills the most recent job (+). alias v %vi alias j jobs alias k 'kill %\!*' alias sysline ~/bin/sysline -Dhmrj :::::::::::::: cshrc/6 :::::::::::::: Date: Fri, 21 Sep 84 01:17:43 cdt From: ihnp4!uiucdcs!liberte (Daniel LaLiberte) To: sun!resonex!nancy Subject: .cshrc trick I like my recursive prompt that shows the depth of shell calls with added ">"s. It also gives a different prompt for my superuser which has the same home. Additionally, we have several vaxes, uiucdcs*, networked with ethernet. Upgrades are easier with the same .cshrc on all machines. ... if (! $?PROMPT) setenv PROMPT "" # initialize setenv PROMPT "$PROMPT>" # add ">" if ($?prompt) then set sys = `hostname` if ("$prompt" == "% ") then # regular user set prompt = `echo $sys | sed s/uiucdcs//` else if ("$prompt" == "# ") then # super user set prompt = "$sys#" endif set prompt = "$prompt\!$PROMPT " endif My login prompt (on uiucdcs) is: 1> A csh call will produce: 1>> Remote login to uiucdcsb, for example: b1> Superuser on uiucdcsb: uiucdcsb#1>> I have an alarm script and a spooled rcp that both use `at`. Daniel LaLiberte ihnp4!uiucdcs!liberte :::::::::::::: cshrc/7 :::::::::::::: Date: Sun, 7 Oct 84 20:35:02 pdt From: Ken Greer To: resonex!nancy Subject: Xmas is early this year... Here's what I thought were the most interesting things in my csh profile. 1. Prompt is (curdir hist#), or [curdir hist#] if running as su. The brackets stack, so if I login as kg and su to kgsu, my prompt is [(curdir hist#)] indicating my previous shell was non-su. In both cases, the current directory always appears in prompt. 2. On that subject, I heartily recommend a separate su login for each su-er on a system. This lets everyone have their own profile, and when they quit you don't have to change the su passwd, just remove their su. 3. The directory stuff. (I prefer it to pushd/popd.) ds - displays directory stack (set to length DSSIZE below). go # - go to directory item number # back - go to previous directory. cd - stack current directory and go to a new one. Oldest directories fall off end of stack (whose size is DSSIZE). 4. The "e" and "ec" commands let you edit the last or any command. If works with a special program. Would you like that? 5. Delete/Undelete - special program. Lets you recover deleted files up to three days (user selectable). 6. Do you know about my tcsh? Not sure how it fits in with tricks though. -Ken # Fancy prompt... if ($?prompt) then if (! $?LEFTPROMPT) setenv LEFTPROMPT "" if (! $?RIGHTPROMPT) setenv RIGHTPROMPT "" if (`whoami` == root) then setenv LEFTPROMPT '['"$LEFTPROMPT" setenv RIGHTPROMPT "$RIGHTPROMPT"']' set path=(~/bin /usr/local/etc /etc /usr/local/bin /usr/ucb /bin /usr/bin .) else setenv LEFTPROMPT '('"$LEFTPROMPT" setenv RIGHTPROMPT "$RIGHTPROMPT"')' set path=(~/bin /usr/local/bin /usr/ucb /bin /usr/bin .) endif alias setprompt 'set prompt = "${LEFTPROMPT}${cwd} \\!${RIGHTPROMPT} "' setprompt alias a alias # directory manipulation... set DSSIZE = 10 if (! $?DS) set DS = (~) a back 'set xx=$DS[$#DS] DS[$#DS]=$cwd; chdir $xx; unset xx; setprompt' a go 'set xx=$DS[\!*] DS[\!*]=$cwd; chdir $xx; unset xx; setprompt' a ds 'echo $DS | tr " " "\012" | cat -n' a cd 'if ($#DS >= $DSSIZE) shift DS; set DS = ($DS $cwd);chdir \!*; setprompt' # virtual remove... a rm del a rm! /bin/rm # edit command... a e '/usr/local/bin/ec \!-1:q' a ec '/usr/local/bin/ec "\!*:q"' # misc... a j jobs a ls '/usr/ucb/ls -F' a tag '/usr/ucb/vi -ta \!*' a ts 'set noglob;eval `tset -s -Q \!*`' a wd 'echo $cwd' endif :::::::::::::: cshrc/8 :::::::::::::: Date: Thu, 13 Sep 84 08:36:47 edt From: sun!decvax!genrad!teddy!dls (Diana L. Syriac) To: genrad!decvax!decwrl!sun!idi!resonex!nancy Subject: Re: Tricks, shell and awk scripts, csh aliases and the like I'm sorry, I don't really have any "tricks" to make life easier, I'm also a rather new Unix user....except for one: I use setenv a lot to define a bunch of directories that I use a lot. For example, I have in my .cshrc: setenv obc ~doc/rts/obc So anytime I want to get to that directory (or just look at it), I just type: ls $obc/filename These environment variables work inside of mail as well as inside of emacs. I suppose you already have that one from other people. We also have on our system some "local" programs that make life a lot easier: We have an "lf" and "dir" that replaces "ls" and "ls -l", but with an added feature: directories are displayed in bold letter, executables are displayed in reverse video and special files are displayed in flashing letters. It's quite easy to see at a glance what the files are or where you want to go. We also have a "pushd" and "popd" which replace the "cd" command. pushd directory will pushd a directory onto the "stack", and change to it. After you're finished with that directory, just typing popd will put you back to where you were. There is a "dirs" command to allow you to look at the "stack" to see where you are, where you've been. If you use "cd" instead, it's smart enough to change your stack and replace the current directory with the one specified in "cd". And if you just say "pushd" by itself, it will SWAP the current directory with the last directory you were in, making it very easy to toggle between two directories. Other things that we've done: Built a script for the nroff command that is used by most people on the system, including macros and some "local" filters to make it look nice on terminal, line printer, and diablo. I have also created a little program which can be used in conjunction with nroff to produce "change bars" at the left margin of documents. We used the change bars quite a lot under vms rno. We have a set of programs that produce "C" listings, with a table of contents showing all files AND routines, page numbered and file numbered, each file has a line number at left margin indicating file and line number (eg: 3.41 refers to file 3, line 41), and at the very end of listing, there is a cross-reference of all tokens, giving file.line references. Part of this set of programs was taken directly off the net and modified for our own use. Well, that's all that I can think of for now. BUT what I really mailed to you was for something that I want. At the last DECUS, one of the speakers demonstrated a little program that he wrote that allowed him to keep a running log of what he did every day. The program started up when he logged on, and ran in the background. Every 15 minutes, it would beep at him, asking him to input a line telling what he was currently doing. If ignored, it would beep at him every minute until he input something to it. I don't know who the guy was, and I lost his business card, but I'd sure like to get that program if you have it. Thanks much. Diana L. Syriac GenRad, Concord, Ma. decvax!genrad!teddy!dls :::::::::::::: logins/1 :::::::::::::: From: sun!dagobah!mike Date: Mon, 17 Sep 84 23:26:53 pdt To: sun!resonex!nancy Subject: .login #tset -m dialup:aaa-60 -Q tset -m dialup:c100-4p -Q setenv TERM $term switch ($TERM) case dialup: set term = aaa-60; setenv TERM $term ~/bin/aaapf breaksw case c100-4: case c108-4p: sysline case c100-4p: setkeys endsw stty new erase "^?" biff y setenv notify true setenv CWD $cwd setenv SHELL /bin/csh setenv MAIL ~/Mail setenv MANPATH /u0/pn/man:/u0/mike/Man:/usr/lfl/man:/usr/man setenv INCPATH /usr/lfl/include:/usr/include:/u0/mike/Include setenv LIBPATH /usr/lfl/lib:/lib:/usr/lib:/u0/mike/Lib setenv LOADPATH /usr/src/lfl/bin/emacs.unipress/emacs4.2/maclib setenv EDITOR /usr/ucb/vi uupoll ucbvax msgs :::::::::::::: logins/2 :::::::::::::: Date: Fri, 14 Sep 84 10:42:43 edt From: Jay Weber To: ut-sally!mordor!dual!amd!resonex!nancy Subject: Re: Tricks, shell and awk scripts, csh aliases and the like I use the hold option in my .mailrc, which keeps messages around until you explicitly delete them. That's a popular option since it makes it easy to keep around descriptions of things to do, but it gets hard to tell when you have new mail and how much. So, I have this in my .login: @ newmail= `from $mail[$#mail] |awk 'END{print NR}'` - `cat .mailsize` if ($newmail == 1) then echo "(There is one new mail message.)" else if ($newmail > 1) echo "(There are $newmail new mail messages.)" endif ------------ and this in my .logout: if (-r $mail[$#mail]) then from $mail[$#mail] | awk 'END{print NR}' >~/.mailsize endif ------------ Jay Weber ..!seismo!rochester!jay jay@rochester.arpa :::::::::::::: logins/3 :::::::::::::: Date: Fri, 14 Sep 84 15:16:00 cdt To: ctvax!convex!allegra!resonex!nancy From: allegra!convex!trsvax!gm (George Moore) Subject: neat .login's Nancy, Here is some of the aliases I use, as well as part of my .login file: (We are running 4.1BSD on a 11/780) alias back 'set back=$old; set old=$cwd; cd $back; unset back' alias cd 'set old=$cwd; chdir \!*; sp' alias sp 'set prompt="$cwd> "' Those aliases allow my prompt to always be my current directory. You never have to run "pwd" again. Looks kindof strange when you are in a low directory like /g/usr/src/local/csh, but you get used to it. It also allows you to cd to some low dir, and then type "back" and you are back in the directory you started in. I have this line in my .login: sh -c "$HOME/bin/firstlog &" This line allows you to spin off a background job without the "[1] 22934" message messing up your screen. Firstlog is done below. I have a security program which goes out and checks a few key files and directories (/etc/passwd, /etc/group, /usr/lib/crontab, /etc). If anything has changed, it sends me mail informing me of the fact. But I only wish it run once a day, at the time I first login for the day. (I don't want it run from crontab, that makes things too predictable for the users) --------------------------------------------------------------------- #! /bin/csh # Firstlog -- finds out if this is the first time I have logged in # today and start-up all sorts of neat stuff if it is. set date=`/bin/date` set now=`/usr/ucb/last $user` if ($date[2] != $now[13] || $date[3] != $now[14]) then sh -c "$HOME/personal/security/secure &" endif --------------------------------------------------------------------- I hope this helps. George Moore gm@trsvax.UUCP From: Nancy Blachman To: net.unix,net.unix-wizards,net.sources Subject: Actual Tricks, shells, csh aliases and the like, 2 of 3 Date: 16 Oct 84 21:22:55 GMT Organization: Resonex Inc., Sunnyvale, CA > [Know anybody with a GREAT .login or .cshrc?] > I'm interested in collecting the little tricks, shell scripts, awk > hacks, csh aliases, and such that people have built to make their daily > life a little easier or more automatic. Being a fairly new system > administrator I don't have the big toolbox that years of messing around > will leave you with. If you have any hacks you're proud of (or that > you aren't proud of, but which work anyway), and you're willing to make > them public, mail them to me. I'll collect, collate, shuffle, sort, > munge, judge, select and discard them and then "summarize to the net". This article focuses shell scripts I received in response to my solicitation. The first article of this series concentrates on aliases, and .cshrc and .login files. The third article centers on C programs and awk scripts. /\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\/ > Nancy Blachman {allegra,hplabs,ihnp4,sun}!resonex!nancy (408)720 8600 x37 < /\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\/ :::::::::::::: shells/1 :::::::::::::: Date: Thu, 13 Sep 84 12:49:57 edt From: allegra!vax135!cornell!tesla!mac (Michael Mc Namara) To: cornell!vax135!houxm!mhuxl!ulysses!allegra!resonex!nancy Subject: Cute cshell - sh scripts If your are like most UNIX systems, you have a plethora of different terminals that your system is supposed to support. Sure, with termcap and terminfo, and programs written to use them, the interface gets easier. If you only ever login to one particular terminal, you can set term = "vt131" or TERM=vt131 export TERM in your .login or .profile. But what if you, or some of your users, drift around using different terminal types-- You have a terminal room with many different terminals. Here is a set of shell scripts & C programs that use the "echo terminal type" command that many terminals support, to do automatic terminal type identification and setting: (of course I've only made it work for the terminals we have here at Cornell, and some day I should write more of it in C...) This one is written for cshell: ########################################## # Identify and set terminal type (csh)# ########################################## set noglob echo Please wait... stty cbreak -echo # this sequence will cause all terminals we have to echo something # except for adm's; those users are told to hit 'a' when they see # please wait echo ' CZ[c' sleep 1 # this calls a c program to grab the id string from the terminal # program is included later... set type = `/usr/new/rin.login` stty -cbreak echo new crt ######################### # the or in the vt100 terminal type is because vt100's respond # to both ^[Z and ^[[c, but DEC threatens to eliminate one of # the responces (I forget which).. The extra stty back you see # with DG terminals (Data General) is because their backspace is # ^Y instead of ^H ( Home on DG terminals) This involves a modification # of stty, which you would care about only if you have them--Write to me. ################## if ( $type == "[?1;0c" || $type == "[?1;0c[?1;0c" ) then set term = vt100 echo "VT101" else if ( $type == "[?1;2c" || $type == "[?1;2c[?1;2c" ) then set term = vt100 echo "VT100" else if ( $type == "[?1;11c[?1;11c") then set term = ct500 echo "[7mCIT - 500[m" else if ( $type == "[?12;5;0;102c" ) then set term = vt100 echo "VT125" else if ($type == "[?1;2c[?1;2c") then set term = vt100 echo "VT100, with Selenar Graphics" else if ( $type == "o#\!R" ) then set term = dg200 stty stop undef start undef back echo "DDG200E" else if ( $type == "o#'C3" ) then set term = dg450 stty back echo "FS11BFS00 DATA GENERAL DASHER D450" else if ( $type == "o#'K3" ) then set term = dg450 stty back echo "FS11BFS00 DATA GENERAL DASHER D450" else if ( $type == "/K" ) then set term = vt52 echo "Visual 50" else if ( $type =~ "\\4*" ) then set term = hp2621 echo HP2621 else if ( $type =~ "a" ) then set term = adm3a echo "adm3a" else if ($type == "50" ) then set term = w50 echo "WYSE50" else # Ask user for terminal type -- for some reason the above didn't work set no_name_yet=1 set no_name_yet = 1; while( $no_name_yet ) echo -n "Please enter terminal type (hit return for menu) " set ttyname = ($< ); switch( $ttyname ) case d450: case dg450: set term=dg450; stty back set no_name_yet = 0; breaksw; case vt100: set term=vt100; set no_name_yet = 0; breaksw; case v50: case vt52: set term=vt52; set no_name_yet = 0; breaksw; case hp2621: case hp: set term=hp2621; set no_name_yet = 0; breaksw; case wyse50: set term=w100; set no_name_yet = 0; breaksw; case adm5: set term=adm5; set no_name_yet = 0; breaksw; case adm3+: case adm3: case adm3a: set term=adm3+; set no_name_yet = 0; case d200: case dg200: set term=dg200; stty stop undef start undef back ; set no_name_yet = 0; breaksw; case other: echo -n "Enter terminal name: " set term=($< ); set no_name_yet = 0; breaksw; case '': echo Terminal abbreviations are: echo "Dasher 450 : dg450" echo "Dasher 200 : dg200" echo "Visual 50 : v50" echo "VT100 : vt100" echo "HP 2621 : hp2621" echo "ADM5 : adm5" echo "ADM3+ : adm3+" echo "Use 'other' to specify terminals not on this menu" breaksw; default: echo "I didn't understand that. Hit return for a menu." endsw end unset no_name_yet unset ttyname endif stty -cbreak stty echo unset noglob Ok, This one is used for Bourne shell lovers: (I used /bin/test because one user had an executable file called test somewhere in his path ahead of where this program lived...That one took days to track down...) echo "Please Wait..." stty start stop crt new back  -echo cbreak echo ' CZ[c' sleep 1 TYPE=`/usr/new/rin.login` stty echo -cbreak if ( /bin/test \( $TYPE = "[?1;0c" \) -o \( $TYPE = "[?1;0c[?1;0c" \) ) then TERM=vt100 echo "[7mVT101[m" elif ( /bin/test \( $TYPE = "[?1;2c" \) -o \( $TYPE = "[?1;2c[?1;2c" \) ) then TERM=vt100 echo "#3[7mVT100[m" echo "#4?[7mVT100[m" elif ( /bin/test $TYPE = "[?1;11c[?1;11c") then TERM=ct500 echo "CT 500" elif ( /bin/test $TYPE = "o#!R" ) then TERM=dg200 stty stop undef stty start undef stty crt stty back echo "D DATA GENERAL DASHER D200E" elif ( /bin/test $TYPE = "o#'C3" ) then TERM=dg450 stty crt stty back echo "FS11BFS00 DATA GENERAL DASHER D450" elif ( /bin/test $TYPE = "/K" ) then TERM=vt52 echo "UVisual 50T" elif ( /bin/test $TYPE = "50" ) then TERM=w50 clear echo "WYSE 50" elif ( /bin/test $TYPE = "\4088000" ) then TERM=hp2621 echo HP2621 elif ( /bin/test $TYPE = "a" ) then TERM=adm3a echo ADM3a else stty start stty stop stty new crt set no_name_yet=1 echo while ($no_name_yet) do { echo echo Which terminal do you have? echo Hit return for a menu. read INP case $INP in 100 | v | vt100) { TERM=vt100 break } ;; adm5) { TERM=adm5 break } ;; adm3+) { TERM=adm3+ break } ;; 450 | dg450 | d450) { TERM=dg450 stty back break } ;; 200 | dg200 | d200) { TERM=dg200 stty stop undef stty start undef stty back break } ;; 50 | vt52 | v50) { TERM=vt52 break } ;; 2621 | hp2621 | hp) { TERM=hp2621 break } ;; other) { echo -n Enter terminal name: read tname TERM=$tname break } ;; ''|?|help) { echo Terminal abbreviations are: echo echo Dasher 450: dg450 echo Dasher 200: dg200 echo Visual 50: vt52 echo VT100 : vt100 echo HP 2621 : hp2621 echo ADM3+ : adm3+ echo ADM5 : adm5 echo "Use 'other' to specify other terminals." echo } ;; * ) { echo "I did not understand that." } ;; esac } done fi export TERM ********* And here is the c program that read's in the terminal ID string: /* rin -- read in a char string which may not be terminated */ char buf[256]; int n; main () { n = read(0,buf,256); write(1,buf,n); printf("\n"); } *************** Use them, abuse them. Of course you have to paw through your terminal manuanls to discover what (if any) string they respond to, and test for the response accordingly... ---MAC :::::::::::::: shells/2 :::::::::::::: From: hplabs!azure!billp To: tektronix!hplabs!resonex!nancy Date: Thursday, 13 Sep 84 09:23:49 PDT Subject: Re: Tricks, shell and awk scripts, csh aliases and the like Here are some that I like and use a lot. 'del' and 'undelete' are just two links to the same file. This way if somebody copies one, they get the other too ------------------------------------------------------------------------------- :::::::::::::: : mv :::::::::::::: : 'prompts if the destination file already exists' /bin/mv -i $* ------------------------------------------------------------------------------- :::::::::::::: : cp :::::::::::::: : 'prompts if the destination file already exists' /bin/cp -i $* ------------------------------------------------------------------------------- :::::::::::::: : del, undelete :::::::::::::: : '"del" throws files into the waste basket' : 'files preceded by "," are automagically removed after 7 days' : '"undelete" pulls files out of the waste basket' : 'if invoked without an argument, both commands list the contents of the' : 'waste basket.' case $0 in *del) if test -z "$1" then ls -lus $HOME/.waste_basket else for i do echo -n "deleting " tmp=`basename $i` /bin/mv -i $i $HOME/.waste_basket/,$tmp echo $i done fi;; *undelete) if test -z "$1" then ls -lus $HOME/.waste_basket else for i do echo -n "recovering " tmp=`basename $i` /bin/mv -i $HOME/.waste_basket/,$tmp $i echo $i done fi;; esac ------------------------------------------------------------------------------- :::::::::::::: : vi :::::::::::::: : 'backs up file(s) before editing them' : 'files preceded by "," are automagically removed after 7 days' for i do if test -f $i then echo -n "backing up " tmp=`basename $i` /bin/cp -i $i $HOME/.vi_backup/,$tmp echo $i fi done /usr/ucb/vi $* ------------------------------------------------------------------------------- Bill Pfeifer {ucbvax,decvax,ihnp4,allegra,uw-beaver,hplabs} !tektronix!tekmdp!billp :::::::::::::: shells/3 :::::::::::::: Date: Thu, 13 Sep 84 13:58:09 pdt From: turtlevax!ken (Ken Turkowski) To: resonex!nancy Subject: Re: Tricks, shell and awk scripts, csh aliases and the like You asked for it, you've got it! Here's ALL of my personal nifties: Ken ************************************************** echo x - bin mkdir bin echo x - bin/CC cat >bin/CC <<'!Funky!Stuff!' # set outname=a.out foreach file ($argv) if ("$file" =~ *.[cso]) then set outname=$file:r break endif end echo cc -o $outname $* exec cc -o $outname $* !Funky!Stuff! echo x - bin/appt cat >bin/appt <<'!Funky!Stuff!' # set notetype=$0 set notetype=$notetype:t set notefile=~/.$notetype # if ($notetype == appt) then # set notetype=appointment # set notefile=~/calendar # endif if ($#argv == 0) then test -t 0 && echo Please enter your $notetype entry '(^D to end):' echo ' ' >> $notefile exec cat >> $notefile endif switch ($1) case -: exec vi $notefile case -rm: cat /dev/null > $notefile exec echo The ${notetype}s are removed. case -what: exec cat $notefile default: echo '' >> $notefile echo "$*" >> $notefile endsw !Funky!Stuff! echo x - bin/asfix cat >bin/asfix <<'!Funky!Stuff!' case $# in 0) file=/tmp/afix$$ trap "cat $file; rm $file; exit" 0 trap "rm $file; exit" 3 9 cat > $file ;; 1) file=$1 ;; *) echo Usage `basename $0` ' [ ]' ;; esac ed - $file << EOF v/[:\.]/s/^/ / g/:./s/:/: / wq EOF !Funky!Stuff! echo x - bin/atcat cat >bin/atcat <<'!Funky!Stuff!' # if ($#argv < 2) then set cmd=$0 echo Usage: "$cmd:t