From owner-freebsd-questions@FreeBSD.ORG Wed Nov 18 02:07:26 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4554C106566B for ; Wed, 18 Nov 2009 02:07:26 +0000 (UTC) (envelope-from msoulier@digitaltorque.ca) Received: from mail.storm.ca (unknown [IPv6:2607:f0b0:0:6:209:87:239:66]) by mx1.freebsd.org (Postfix) with ESMTP id 4D9BE8FC0A for ; Wed, 18 Nov 2009 02:07:24 +0000 (UTC) Received: from anton.digitaltorque.ca (hs-216-106-102-79.storm.ca [216.106.102.79]) by mail.storm.ca (8.14.2+Sun/8.14.2) with ESMTP id nAHNTliG013121; Tue, 17 Nov 2009 18:29:52 -0500 (EST) Received: by anton.digitaltorque.ca (Postfix, from userid 1000) id 2BFAB860232; Tue, 17 Nov 2009 18:29:41 -0500 (EST) Date: Tue, 17 Nov 2009 18:29:41 -0500 From: "Michael P. Soulier" To: Polytropon Message-ID: <20091117232940.GB6951@anton.digitaltorque.ca> Mail-Followup-To: Polytropon , freebsd-questions@freebsd.org References: <20091115231424.GA29418@anton.digitaltorque.ca> <20091116031758.0729246c.freebsd@edvax.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="b5gNqxB1S1yM7hjW" Content-Disposition: inline In-Reply-To: <20091116031758.0729246c.freebsd@edvax.de> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-questions@freebsd.org Subject: Re: bash prompt update lagging X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2009 02:07:26 -0000 --b5gNqxB1S1yM7hjW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 16/11/09 Polytropon said: > Your PS1 seems to include ${SHORT_PWD}, a variable. It seems > that it is not updated immediately after the cd command. Yeah, looks like it. Works on linux though... > By the way, this is bash-3.2.25 on FreeBSD/x86 7. bash-4.0.33_2 on x86 6.3. > Is this what you've intended the prompt to look like? I'm using an awk script to truncate any pwd that's too long. get_short_pwd() { # The actual max length is max_len + the length of trunc_symbol local max_length=3D$1 local trunc_symbol=3D"..." if [ -z "$max_length" ]; then max_length=3D20 fi if [ "$PWD" !=3D "$OLDPWD" ]; then SHORT_PWD=3D$(awk "BEGIN { =20 path =3D ENVIRON[\"PWD\"] home =3D ENVIRON[\"HOME\"] home_len =3D length(home) max_len =3D $max_length sym_len =3D length(\"$trunc_symbol\") if(substr(path, 0, home_len) =3D=3D home) { path =3D sprintf(\"~%s\", substr(path, home_len + 1)) } path_len =3D length(path) if (path_len > max_len) { path =3D sprintf(\"%s%s\", \"$trunc_symbol\", substr(path, = path_len + sym_len - max_len + 1)) } print path }") OLDPWD=3D${PWD} fi } This is called via a build_prompt() function in my .bashrc. I guess I'll ec= ho out some variables there and see what's happening. FTR this did work, and then I updated bash in ports. Mike --=20 Michael P. Soulier "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction." --Albert Einstein --b5gNqxB1S1yM7hjW Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) iD8DBQFLAzHkKGqCc1vIvggRAlTYAKCyQTKhgNE5JrnrUvUx/1UwNQ86SACgs9e1 1GAWmhp3aktW7PWrOZG9uF8= =KXWI -----END PGP SIGNATURE----- --b5gNqxB1S1yM7hjW--