Prompt as Current Directory?

Christopher Davis ckd at bu-pub.bu.edu
Thu Nov 16 23:51:42 AEST 1989


>>>>> On 16 Nov 89 05:56:13 GMT, broadman at paul.rutgers.edu (Alan Broadman)
>>>>> said:

Alan> I have a (hopefully) simple question. How can you get the UNIX prompt
Alan> to always reflect the path to the current directory. Such a prompt
Alan> would change with each 'cd ' command. In MS-DOS this is done by the
Alan> command : 'prompt $P'. I think this would be most helpful, as
Alan> otherwise, the prompt string is quite useless.

Depends--what shell are you using?  If you're using tcsh (or can chsh to
it, or can get your sysadmin to put it up, etc) you can just do what I do:

set prompt="%t ckd@%m : %~ %% "

which results in something like:

7:47am ckd at bucsf : ~/bin % 

the %m being the short hostname (hey, you use multiple machines, you start
to need these memory joggers when you get old) and the %~ being the magic
part that puts the current working directory in there (properly
~-abbreviated when I'm in my own directory tree).

See man tcsh, again assuming you can get it set up--it's got other nice
stuff, such as emacs-like command line editing (as well as some
vi-like editing, I hear, but I wouldn't know... :-), tab completion of
commands and filenames, et. al.

If you can't get tcsh, let me dig out this unghodly set of aliases I stole
from someone (who stole them from someone, who stole them from someone,
unto their forefathers before them, yea, verily...) that put the hostname
and trailing directory component into the prompt.  They wouldn't be hard to
hack to put the full cwd in.
-- 
 Christopher Davis, BU SMG '90  <ckd at bu-pub.bu.edu> <smghy6c at buacca.bitnet>
 "Technology is dominated by those who manage what they do not understand."



More information about the Comp.unix.questions mailing list