Gentoo Archives: gentoo-user

From: Philip Webb <purslow@××××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] bash scripting tip
Date: Fri, 12 Nov 2010 18:32:28
Message-Id: 20101112183151.GJ4443@ca.inter.net
In Reply to: Re: [gentoo-user] bash scripting tip by Bill Longman
1 101112 Bill Longman wrote:
2 > On 11/12/2010 09:57 AM, Philip Webb wrote:
3 >> but is there a way to set up a command to goto a parallel dir,
4 >> eg if you're in ~/tmp goto ~/hold ( 2 of my commonly-used dirs) ?
5 >> The elegant way is 'function cd2() { cd .. ; cd $"$1" ; }'.
6 > cd ${PWD/old/new}
7 > works when you're in /some/old/tree/directory
8 > and you want to go to /some/new/tree/directory
9
10 It works, but wouldn't be as useful for what I want to do,
11 as you'ld have to enter both 'old' & 'new' after the function command.
12 ie instead of 'cd2 hold', you'ld have to write 'cd2 tmp hold':
13 it doesn't work if you try 'cd ${PWD/./hold}', which leaves you in 'tmp'.
14
15 For generally jumping round the dir tree, I recommend Cdargs.
16
17 --
18 ========================,,============================================
19 SUPPORT ___________//___, Philip Webb
20 ELECTRIC /] [] [] [] [] []| Cities Centre, University of Toronto
21 TRANSIT `-O----------O---' purslowatchassdotutorontodotca