dheller@cory.Berkeley.EDU (Dan Heller) (06/23/88)
In article <cWj4wfy00VoD07K1QF@andrew.cmu.edu> jl42+@psuvax1.UUCP (Jay Mathew Libove) writes: >that directory gives me this path for example: > >MISTERDATA/afs/cs.cmu.edu/bsd4.3/ibm032/omega/usr/misc/.X11tra/lib/awm/bitmaps:(120) % > >Cute, huh? Oh well, I think its worth it, even if my prompt *does* exceed >one screen width :-) (After all, that's what 132 column Xterm windows are >for, right? hee hee) I hate long prompts -- I usually know where I am when I set my prompt to the current directory and the one above: alias cd 'chdir \!* ; set cwdh = $cwd:h ; set prompt = "[$cwdh:r/$cwd:r] % "' Therefore, your prompt would look like: [awm/bitmaps] % Dan Heller <island!argv@sun.com>
rcsmith@anagld.UUCP (Ray Smith) (06/23/88)
In article <cWj4wfy00VoD07K1QF@andrew.cmu.edu> jl42+@psuvax1.UUCP (Jay Mathew Libove) writes: >Two cshell prompt ideas have been posted to comp.sources.misc in the >past week or so, so I thought I'd relate a funny reality about cshell >prompts... > >On some systems, specifically those that are huge remote file >systems (like that of the andrew project at Carnegie Mellon >University) paths occasionally get like: > >/afs/cs.cmu.edu/bsd4.3/ibm032/omega/usr/misc/.X11tra/lib/awm/bitmaps > >and since my prompt is (quite similarly to one of the ones just >posted) > >machinename/path(linenumber) > >that directory gives me this path for example: > >MISTERDATA/afs/cs.cmu.edu/bsd4.3/ibm032/omega/usr/misc/.X11tra/lib/awm/bitmaps:(120) % > <A few lines have been deleted> I wrote a little tool some time back that helps with the extra long path prompt problem. What it basically does is return the last few directories of a long prompt up to TOO_LONG characters or the last directory entry no matter how long it is. I put it as part of my "cd" alias in .cshrc as follows: alias cd 'set old=$cwd; chdir \!*;\ (Line broken here due to length limits) set prompt="`short.prompt $cwd` ($USER - $HOST) $LEVEL-> "' An example of how this looks follows: /usr1/rcsmith (rcsmith - anagld)-> cd source ~/rcsmith/source (rcsmith - anagld)-> cd tools ~/source/tools (rcsmith - anagld)-> The code ain't real pretty and I haven't investigated it for making it faster or anything. I am sure someone will find ways to enhance it. It is just a quick little tool I threw together. In fact it took longer to add all the comments so that I could post it than it took to write. If I should have put it in a 'shar' with all types of docs and stuff I apologize, I just thought some body could use it. Enjoy, Ray ---------------------------Cut here---------------------------------------- #define TOO_LONG 15 /* HOW MUCH TO BE PRINTED */ #include <stdio.h> main(argc,argv) int argc; char **argv; { int i, j; /* DECLARE SOME COUNTERS */ char *cp; /* AND A POINTER */ *argv++; /* INCREMENT ARGV SO THAT IT */ cp = *argv; /* POINTS TO THE PATH AND SET */ /* THE OTHER POINTER */ if (*argv == '\0') /* IF THERE IS NO ARGUMENT */ return (-1); /* JUST GET OUT - ABNORMAL EXIT*/ else i = strlen (*argv); /* SEE HOW LONG THE ARG IS */ if (i > TOO_LONG) { /* IF THE LENGTH IS TOO LONG */ for (j=0; j < i; j++) { /* FIDDLE WITH THE COUNTERS & */ if (i-j > TOO_LONG) { /* POINTER TO SET IT FOR AT*/ *cp++; /* LEAST too_long CHARACTERS */ } } while (*cp != '/' && *cp != '\0') /* FIND THE LAST SLASH OR*/ *cp++; /* THE END */ if (*cp == '\0') { /* IF WE ARE AT THE END WE NEED*/ while (*cp != '/') /* TO BACK UP TILL WE FIND THE*/ *cp--; /* LAST SLASH */ } if (strcmp (cp, argv) != 0) /* IF THEY DON'T POINT TO THE */ printf ("~"); /* THING WE PRINT A '~' TO */ /* INDICATE MORE */ } printf ("%s", cp); /* NOW PRINT THE STRING */ } ---------------------------Cut here---------------------------------------- -- Ray Smith | USnail: Suite 200, 9891 Broken Land Pky, Columbia, MD 21046 Analytics, Inc. | GEnie : rcsmith (301) 381-4300 | CIS : 72000,1111 | Net : ...!uunet!mimsy!aplcen!anagld!rcsmith =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= "The trouble with doing something right the first time is that nobody appreciates how difficult it was." -Walt West =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
tif@cpe.UUCP (06/24/88)
Written 6:32 pm Jun 19, 1988 by psuvax1.UUCP!jl42+ in cpe:comp.sources.d >MISTERDATA/afs/cs.cmu.edu/bsd4.3/ibm032/omega/usr/misc/.X11tra/lib/awm/bitmaps:(120) % > >Cute, huh? Oh well, I think its worth it, even if my prompt *does* exceed >one screen width :-) (After all, that's what 132 column Xterm windows are >for, right? hee hee) Well, I was gonna stay out of this but I have my own solution to this. Those long prompts are really obnoxious at lower baud rates. Chances are you had a pretty good idea where you were, you just needed a hint. The last two components are probably sufficient. My prompt would only print awm/bitmaps:120 If you're interested here's mine: alias cd 'chdir \!*; set cwd=`pwd`;\\\ set head=$cwd:h; set prompt="$head:t/$cwd:t:\! "' I suppose if you wanted three components you could use (untested) alias cd 'chdir \!*; set cwd=`pwd`;\\\ set head1=$cwd:h head2=$head1:h;\\\ set prompt="$head2:t/$head1:t/$cwd:t:\! "' P.S. add "cd ." to the end of .cshrc to initialize it. I can't decide if "pwd" should be "/bin/pwd" or not. And yes, it behaves when your at / (at least the first one does). Actually, my real prompt would print it in reverse video and replace the colon with a pound sign if I was root. I don't like having to look hard to find my prompt. :-) Paul Chamberlain Computer Product Engineering, Tandy Corp. ihnp4!sys1!cpe!tif