Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!sol.ctr.columbia.edu!emory!mephisto!prism!gt0178a From: gt0178a@prism.gatech.EDU (BURNS,JIM) Newsgroups: comp.unix.shell Subject: Re: command line prompt (need current directory) Message-ID: <13669@hydra.gatech.EDU> Date: 14 Sep 90 11:29:42 GMT References: <1683@ispi.COM> Distribution: comp Organization: Georgia Institute of Technology Lines: 47 in article <1683@ispi.COM>, jbayer@ispi.COM (Jonathan Bayer) says: > I have a customer who wants/needs the prompt to show the current > directory (similar to MS-DOS :-( ). I reached back into my archives > and pulled out the following script: In .kshrc, I do: PS1="{${HOSTNAME}"':${PWD}}\ [!] ' In .cshrc, I do: alias cd 'cd \!*;set prompt="`hostname``pwd`> [\\!] % "' cd `pwd` Putting them in the rc's executes them for each subshell. (The !'s are the current history #'s.) > spawned. The new shell does not inherit the shell function. My > questions are: > > 1. How can I make the new shell inherit shell functions? Ksh allows you to export functions with (for me): typeset -fx cp ll man I'm not aware of any way to do it in sh, and haven't run across any csh's that support functions, per se (not aliases). > 2. Is it possible to have a shell function have the same > name as a real function (ie: name this function "cd", > and have it use the normal "cd" to change the > directory)? Most shells will search for a builtin before executing an alias or function. For a function that replaces the behavior of an external, specify the pathname for the 'inside' invocation of the command, as in: ll () { /bin/ls -alF $* | more ; } This can be particularly important in shells that allow recursion! -- BURNS,JIM Georgia Institute of Technology, Box 30178, Atlanta Georgia, 30332 uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt0178a Internet: gt0178a@prism.gatech.edu