[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] prompt help
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] prompt help |
Date: |
Mon, 13 Feb 2012 16:12:00 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
On 2/13/12 3:44 PM, Greg Wooledge wrote:
> On Mon, Feb 13, 2012 at 09:13:27PM +0100, Geir Hauge wrote:
>> And here's using Chet's idea and with a different way of parsing PWD.
>> Putting the following block of code in ~/.bashrc should give you the
>> desired effect.
>>
>> setmypwd() {
>> mypwd=$(
>> while read -rd /; do
>> printf /%.1s "$REPLY"
>> done <<< "${PWD#/}"
>> printf /%s "$REPLY"
>> )
>> }
>
> This is forking a subshell, though. You can get around that by building
> up the mypwd variable directly:
While that's true, I argue that you can absorb the cost of a subshell if
you're only running this when you change directories.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/