|
Home > Archive > Unix Shell > August 2007 > Aliasing CD command
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 |
Aliasing CD command
|
|
| Pablo López 2007-08-26, 1:20 pm |
| I want to aliase the 'cd' command.
Actually, i clear the screen before the cd command:
alias cd='clear; cd'
But now, i want to do more. I want to do a `ls` after the process, but
i can't change the directory because the parameters.
Maybe i have to pass the parameters to the alias but i don't know how.
It seems to be something similar to this:
alias cd='clear; cd $@; ls -lahF --color'
But it don't works.
Thanks for your time.
| |
| Cyrus Kriticos 2007-08-26, 1:20 pm |
| Pablo López wrote:
> I want to aliase the 'cd' command.
>
> Actually, i clear the screen before the cd command:
>
> alias cd='clear; cd'
>
> But now, i want to do more. I want to do a `ls` after the process, but
> i can't change the directory because the parameters.
> Maybe i have to pass the parameters to the alias but i don't know how.
> It seems to be something similar to this:
>
> alias cd='clear; cd $@; ls -lahF --color'
>
> But it don't works.
[bash]
Solution without alias:
cd () { clear; builtin cd $1; ls -lahF --color; }
--
Best | "Was bekommt man/frau, wenn man/frau Software kauft?
regards | Nichts außer einem Haufen Nullen und Einsen."
Cyrus | -- aus d. Lizenzvereinbarung von Spybot Search&Destroy
| |
| Cyrus Kriticos 2007-08-26, 1:20 pm |
| Pablo López wrote:
> I want to aliase the 'cd' command.
>
> Actually, i clear the screen before the cd command:
>
> alias cd='clear; cd'
>
> But now, i want to do more. I want to do a `ls` after the process, but
> i can't change the directory because the parameters.
> Maybe i have to pass the parameters to the alias but i don't know how.
> It seems to be something similar to this:
>
> alias cd='clear; cd $@; ls -lahF --color'
>
> But it don't works.
[bash]
alias cd='XxX () { clear; builtin cd $1; ls -lahF --color; }; XxX'
--
Best | "Was bekommt man/frau, wenn man/frau Software kauft?
regards | Nichts außer einem Haufen Nullen und Einsen."
Cyrus | -- aus d. Lizenzvereinbarung von Spybot Search&Destroy
| |
| Pablo López 2007-08-26, 1:20 pm |
| > alias cd='XxX () { clear; builtin cd $1; ls -lahF --color; }; XxX'
It's perfect, and works.
Thanks!!
| |
| Scofield 2007-08-26, 1:20 pm |
| Pablo López wrote:
> I want to aliase the 'cd' command.
>
> Actually, i clear the screen before the cd command:
>
> alias cd='clear; cd'
>
> But now, i want to do more. I want to do a `ls` after the process, but
> i can't change the directory because the parameters.
> Maybe i have to pass the parameters to the alias but i don't know how.
> It seems to be something similar to this:
>
> alias cd='clear; cd $@; ls -lahF --color'
>
> But it don't works.
>
> Thanks for your time.
>
cd () { clear; \cd $1; ls -lahF --color; }
| |
| hymie! 2007-08-27, 7:23 am |
| In our last episode, the evil Dr. Lacto had captured our hero,
=?iso-8859-1?B?UGFibG8gTPNwZXo=?= <pablolopeztorres@gmail.com>, who said:
>I want to do a `ls` after the [cd]
Let me assure you that this is a bad idea. You'll find this out
the first time you cd into a directory with hundreds or thousands
of files in it.
--hymie! http://lactose.homelinux.net/~hymie hymie@lactose.homelinux.net
------------------------ Without caffeine for 300 days ------------------------
|
|
|
|
|