Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!eecae!tank!mimsy!eneevax!haven!umbc3!rostamia From: rostamia@umbc3.UMBC.EDU (Rouben Rostamian) Newsgroups: comp.unix.questions Subject: Re: Getting UNIX prompt to display curr Message-ID: <1823@umbc3.UMBC.EDU> Date: 22 Mar 89 05:15:28 GMT References: <5582@ncsugn.ncsu.edu> <47800029@uxe.cso.uiuc.edu> Reply-To: rostamia@umbc3.umbc.edu.UMBC.EDU (Rouben Rostamian) Organization: University of Maryland, Baltimore County Lines: 47 Here are a couple of sicko aliases that set the prompt to the current directory. The first: alias cd cd \!\*\; set prompt = \ pwd \| awk \'BEGIN \{FS=\"/\"\} \{print \$\'NF\'\}\'\`\"\> \" causes "cd" to change directory and set the prompt to "thisdir> ", where "thisdir" is the name of the current directory only, *not* its full pathname. The second: alias asdf cd \!\*\; set prmpt = \`pwd \| awk \'BEGIN \{FS=\"/\"\} \ \{cnt = NF\; cnt -- \; \ printf \"\%-1s/\%-1s\>\", \$\'cnt\', \$\'NF\' \}\'\` \; \ set prompt = \"\$prmpt \" causes "cd" to change directory and set the prompt to "parentdir/thisdir> ", where "parentdir" is the name of the parent directory of the current directory. These definitions are mildly machine-dependent. As they are, they both work in Ultrix. When I tried them on an Ardent Titan running System V, I had to add a semicolon after the BEGIN{...} statements. (If you are really going to make the change, you should insert a \; after the closing brace of each BEGIN{...} statement. P.S.1: I do not use these aliases myself -- I would rather stick to a fixed, well-chosen, pre-defined prompt and do 'pwd' when I forget where I am in the directory tree. P.S.2: Someone posted a solution recently for making the prompt the *full* pathname of the current directory. The solutions above were inspired by that posting. P.S.3: To those people who continue flaming about frequent and repeated postings of elementary questions in this news group: Short of starting a comp.unix.questions.elementary, if the answer to the question is really short and simple, please just post it and let it go at that. More boring than silly questions are flames about silly questions. -- Rouben Rostamian Department of Mathematics e-mail: University of Maryland Baltimore Counnty Rostamian@umbc2.bitnet Baltimore, MD 21228 rostamia@umbc3.umbc.edu