[ale] cd in bash or ksh, how to do this
Richard Bronosky
Richard at Bronosky.com
Wed Sep 22 14:09:08 EDT 2010
However, if you insist on making a cd replacement with that interface,
simplify it down to:
function cd () {
if [ -n "$2" ] ; then
builtin cd "${PWD/foo/bar}"
else
builtin cd "$@"
fi
}
BTW, quoting is important! Directory names do often have spaces. So,
my previous reply should have been:
function ced () { nd="$(pwd | sed "$@")" && cd "$nd"; }
>> function cd () {
>> if [ -n "$2" ] ; then
>> nd=`pwd | sed 's/'$1'/'$2'/'`
>> builtin cd $nd
>> else
>> builtin cd $1
>> fi
>> }
>>
>> bash$ cd /usr/lib/
>> bash$ pwd
>> /usr/lib
>> bash$ cd usr var
>> bash$ pwd
>> /var/lib
--
.!# RichardBronosky #!.
More information about the Ale
mailing list