*BSD News Article 41009


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msunews!agate!howland.reston.ans.net!news.cac.psu.edu!news.pop.psu.edu!hudson.lm.com!godot.cc.duq.edu!ddsw1!news.cic.net!locust.cic.net!pauls
From: pauls@locust.cic.net (Paul Southworth)
Newsgroups: comp.unix.bsd
Subject: Re: Question re prompt.
Followup-To: comp.unix.shell
Date: 18 Jan 1995 18:35:30 GMT
Organization: CICNet, Inc.
Lines: 25
Message-ID: <3fjn1i$m1b@spruce.cic.net>
References: <3f2ggi$k2n@eplet.mira.net.au>
NNTP-Posting-Host: locust.cic.net

In article <3f2ggi$k2n@eplet.mira.net.au>,
Pete Martin <petemart@pyromania.apana.org.au> wrote:
>Hi all.  How do I set the prompt to display current directory in FreeBSD 
>ver 2?
>
>I know it starts with set prompt=????

This question should go on comp.unix.shell or comp.unix.questions.

The way I do what you're asking (in csh/tcsh) is:

        set prompt = "{`pwd`} `hostname | cut -f1 -d.`% "
        set host = `hostname | cut -f1 -d.`
        alias cd 'chdir \!*; set prompt = "{`pwd`} $host% "'

If you don't have cut, sed is fine, but cut is faster.  For example:

        set prompt = "{`pwd`} `hostname | sed 's/\..*//'`% "
        set host = `hostname | sed 's/\..*//'`
        alias cd 'chdir \!*; set prompt = "{`pwd`} $host% "'

--
Paul Southworth
CICNet Systems Support
pauls@cic.net