Unix Shell - cd alias

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > January 2006 > cd alias





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author cd alias
Michael Tosch

2006-01-19, 6:24 pm

Hi,

in csh/tcsh I have an alias

alias cd 'cd \!*; echo $cwd'

and I would like to have this in bash-2.

The man page says I cannot refer to arguments in an alias,
I need a function.
In a function I can refer to it as "$@", but

cd(){
\cd "$@"
echo $PWD
}

continuesly calls itself, because the escape \cd
does not work for a function (only works for an alias).

Suggestions?


--
Michael Tosch @ hp : com
Stephane Chazelas

2006-01-19, 6:24 pm

On Thu, 19 Jan 2006 15:28:00 +0100, Michael Tosch wrote:
> Hi,
>
> in csh/tcsh I have an alias
>
> alias cd 'cd \!*; echo $cwd'
>
> and I would like to have this in bash-2.


cd() {
builtin cd "$@"
pwd
}

--
Stephane
Michael Tosch

2006-01-19, 6:24 pm

Stephane Chazelas wrote:
> On Thu, 19 Jan 2006 15:28:00 +0100, Michael Tosch wrote:
>
>
>
> cd() {
> builtin cd "$@"
> pwd
> }
>


Thanks!

--
Michael Tosch @ hp : com
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com