Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!umd5!brl-adm!husc6!ut-sally!utah-cs!utah-gr!spline.utah.edu!thomas From: thomas%spline.utah.edu.uucp@utah-gr.UUCP (Spencer W. Thomas) Newsgroups: comp.emacs Subject: Re: Emacs csh alias Message-ID: <2273X@utah-gr.UUCP> Date: 21 Jan 88 00:00:00 GMT References: <8712041951.AA21105@ucbvax.Berkeley.EDU> <1059@mips.UUCP> Sender: news@utah-gr.UUCP Reply-To: thomas%spline.utah.edu.UUCP@utah-gr.UUCP (Spencer W. Thomas) Organization: University of Utah CS Dept Lines: 66 Here is a pair of aliases that I've been using for years. The real work is done by the 's' alias and the start command: alias e 's emacs \!*' alias s 'jobs >~/.pcs; eval `start < ~/.pcs \!*`' Here is start.c: /* * start - figure out if a process is already running * from the output of the csh's "jobs" command. */ #include char *index(), *rindex(); main(argc, argv) char **argv; { register char *cp; int parens = 0; char line[512]; if (argc <= 1) exit(1); while (gets(line) > 0) { if ((cp = index(line, 'S')) == NULL) continue; if (strncmp(cp, "Stopped", 7) != 0) continue; for (cp += 7; *cp; cp++) { if (*cp == '(') parens++; if (parens == 0 && *cp != ' ') break; if (*cp == ')') parens--; } if (*cp == 0) continue; if (strncmp(cp, argv[1], strlen(argv[1])) != 0) continue; if (argc > 2) fprintf(stderr, "Arguments ignored for continue of %s\n", argv[1]); cp = index(line, ']'); *cp = 0; cp = index(line, '[') + 1; printf("%%%s\n", cp); exit(0); } /* Not already running: start it up */ for (argv++, argc--; argc > 0; argv++, argc--) printf("%s ", *argv); printf("\n"); exit(0); } =Spencer ({ihnp4,decvax}!utah-cs!thomas, thomas@cs.utah.edu)