From owner-freebsd-questions Tue Aug 4 01:46:06 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA19029 for freebsd-questions-outgoing; Tue, 4 Aug 1998 01:46:06 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from picasso.tellique.de (picasso.tellique.de [62.144.106.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA18998 for ; Tue, 4 Aug 1998 01:46:01 -0700 (PDT) (envelope-from ni@tellique.de) Received: from tellique.de (nolde.tellique.de [62.144.106.52]) by picasso.tellique.de (8.8.8/8.8.8) with ESMTP id KAA08158; Tue, 4 Aug 1998 10:45:37 +0200 (MET DST) Message-ID: <35C6CB7C.729CC0A@tellique.de> Date: Tue, 04 Aug 1998 10:51:08 +0200 From: Juergen Nickelsen Organization: Tellique Kommunikationstechnik GmbH X-Mailer: Mozilla 4.05 [en] (WinNT; I) MIME-Version: 1.0 To: Studded CC: freebsd-questions@FreeBSD.ORG Subject: Re: BASH prompt question References: <35C657D9.4B2577D4@dal.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 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