Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!sri-spam!ames!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!hpsal2!hpcupt1!hpindda!hpisoa2!spuhler From: spuhler@hpisoa2.HP.COM (Tom Spuhler) Newsgroups: comp.unix.wizards Subject: Re: Emacs csh alias Message-ID: <1020001@hpisoa2.HP.COM> Date: Mon, 7-Dec-87 16:45:58 EST Article-I.D.: hpisoa2.1020001 Posted: Mon Dec 7 16:45:58 1987 Date-Received: Sun, 13-Dec-87 13:34:21 EST References: <10672@brl-adm.ARPA> Organization: Hewlett Packard, Cupertino Lines: 36 >I've been trying to set up a C-Shell (4.2 BSD) alias for Emacs (GNU >17.64, not that it matters) which, when run the first time will >actually run Emacs, but after suspending Emacs with C-z, will bring >the background Emacs job to the foreground. The catch is that I'd >also like the alias to re-load emacs if I exit with C-x C-c. Simply >stated, I want an alias named "emacs" which will load Emacs if it >isn't already loaded, but will foreground a background Emacs if one >exists. > >I know I could do this with a script (if I assume the Emacs job is >always job %1), but I'd prefer an alias since they're faster. It >would be especially nice to determine which background job was the >Emacs job and foreground *it*, instead of just assuming job %1. I have the following script (called 'v') which works for 'vi' and would only require a tiny twiddle to work for emacs instead: ------------ # must be sourced jobs | grep -l ' vi ' >/dev/null if ( $status == 0 ) then fg %vi else vi $* endif ------------ This script must be sourced (as anything that acts on the current shell) and just looks to see if the command exists (note the leading spaces) and 'fg's it if it does or reinvokes it otherwise. change 'vi' to 'emacs' and you should be there. The easy way, just do a 'fg %vi' and check to see if it works if not reinvoke, doesn't quite work correctly as $status = 1 if the fg'd program doesn't exist OR is resuspened, or some other builtin problems crop up. --Tom by the by, I did this on hpux s800 1.2