connet@sal52.usc.edu (David Connet) (01/25/89)
How do I set a csh prompt from witn a c-program? I'm trying to do is: strcpy(ps1,"PS1=new prompt: "); if (putenv(ps1)) fprintf(stderr,"%s: Environment not set up correctly.\n",pgmname); system(shell); This works under sh and ksh. But not csh. Can anyone help? Thanks in advance. Dave Connet connet@castor.usc.edu PS: Please reply via email as I don't read this group.
kwb@hpmtlx.HP.COM ($Keith Blackwell) (01/28/89)
| strcpy(ps1,"PS1=new prompt: "); | if (putenv(ps1)) | fprintf(stderr,"%s: Environment not set up correctly.\n",pgmname); | system(shell); Csh doesn't use an environment variable for the prompt, so theoretically, there's no way to do it. Of course, you could always try to find a way to use .cshrc --- but probably no luck there either for your application. Actually, I tried doing the following from sh (to see if you could use this command in your "system" call instead of just "csh -f" or whatever): (echo 'set prompt="new prompt: "' ; cat - ) | exec csh Needless to say, it didn't work. The prompt was set alright, but csh didn't think it was interactive and didn't bother printing the prompt out! Maybe someone knows a way to convince csh that it *is* interactive? It would be a shame to have to use pseuto-tty's. -- Keith Blackwell NOTE: email to most posters doesn't work from here. Anyway, its interesting...
gandalf@csli.STANFORD.EDU (Juergen Wagner) (01/31/89)
I don't like the idea of setting the csh prompt that way but there is not too much of a choice here. How about if ( -f ~/.promptdef ) then source ~/.promptdef endif in your .cshrc (inside the interactive part). You could write arbitrary command into that file, and could have them executed every time a csh is fired up. Oh, you don't want it to be every time? Just set some environment variable USE_PROMPTDEF to, say, YES, and include a unsetenv USE_PROMPTDEF after the source command. I know, it's a weird way of accomplishing the task, but probably general enough, and it works. If you want to hardwire the prompt, you don't need the "source...", just put you prompt definition here. -- Juergen Wagner gandalf@csli.stanford.edu wagner@arisia.xerox.com