Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 04 Aug 1998 10:51:08 +0200
From:      Juergen Nickelsen <ni@tellique.de>
To:        Studded <Studded@dal.net>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: BASH prompt question
Message-ID:  <35C6CB7C.729CC0A@tellique.de>
References:  <Pine.LNX.3.96.980803142023.11763B-100000@www.schell.de> <35C657D9.4B2577D4@dal.net>

next in thread | previous in thread | raw e-mail | index | archive | help

Studded wrote:

> Why call a shell function every time you hit return?

While I don't do that, I call even a program every time I cd.

cd () { builtin cd "$@" ; setprompt ; }
setprompt () { PS1=": ${HOST}:`echo $PWD | 
    sed -e 's|.*[^/]\(/[^/]*/[^/]*\)|...\1|'`; " ; } ;;

This gives me the following prompt:

: dix:/home/ni; 
: dix:/home/ni; cd src/mnsim
: dix:.../src/mnsim; 
: dix:.../src/mnsim; cd /usr/local/bin
: dix:.../local/bin; 
: dix:.../local/bin; cd /
: dix:/; cd bin
: dix:/bin; 

(a) I have the PWD in the path, but no more than two components of it.
(b) I can cut and paste the complete line if I want to repeat a command,
    because the prompt itself is just an empty shell command (":").

If anyone knows how I can accoplish (a) without calling sed (or awk, or
perl, ... :-), 	I'd appreciate a hint.

Greetings, Juergen.

-- 
Juergen Nickelsen <ni@tellique.de>
Tellique Kommunikationstechnik GmbH
Gustav-Meyer-Allee 25, 13355 Berlin, Germany
Tel. +49 30 46307-552 / Fax +49 30 46307-579

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?35C6CB7C.729CC0A>