1 |
There are quick'n'easy commands to goto the previous dir |
2 |
-- 'cd -' , which cb aliased as 'p' -- |
3 |
& goto the next-higher dir -- 'cd ..' , which cb aliased as 's' -- , |
4 |
but is there a way to set up a qne command to goto a parallel dir, |
5 |
eg if you're in ~/tmp goto ~/hold ( 2 of my commonly-used dirs) ? |
6 |
|
7 |
It needs to be a Bash function, so in ~/.bashrc |
8 |
I tried 'function cd2() { cd .. ; cd $1 ; }', |
9 |
so that 'cd2 hold' would take me where I wanted to go, |
10 |
but it simply dropped me in ~ , the 2nd half being ignored. |
11 |
|
12 |
It cb done with a shell var, |
13 |
ie 'function cd2() { NEWDIR=$1 ; cd .. ; cd $NEWDIR ; NEWDIR= ; }', |
14 |
which works but is a bit lengthy & could clash with an existing shell var. |
15 |
|
16 |
The elegant way is 'function cd2() { cd .. ; cd $"$1" ; }' ; |
17 |
the " ... " are essential: it fails without them or with ( ... ) instead. |
18 |
|
19 |
HTH a few others. |
20 |
|
21 |
-- |
22 |
========================,,============================================ |
23 |
SUPPORT ___________//___, Philip Webb |
24 |
ELECTRIC /] [] [] [] [] []| Cities Centre, University of Toronto |
25 |
TRANSIT `-O----------O---' purslowatchassdotutorontodotca |