Linux cd .. command
Solution 1:
The classic way of doing this is setting the CDPATH
variable. In your case it could be set to .:../../../../
or .:/path/to/the/parent/of/foo
to achieve the desired effect. You can then simply do cd foo/sub1/bar/dest
and get to where you want.
The advantage of this is that tab completion for cd
also looks at $CDPATH
and will magically work.
Solution 2:
You can use autojump which automatically learn from previous cd command and you only need to specify unique string from full path next time. ex.
j foo
,
j foo1
,
j foo2