

Cd command is broken - jiyinyiyong

Everyone who knows `cd` kowns there's another command called `ls`. `ls` is always typed after `cd`. Like `cd project`, ls`.<p>Everyone wants to read child files as soon as he enters a directory, and `ls` is the command.<p>But why are `cd` and `ls` the same command. <i></i>Enter a directory<i></i> is <i></i>an<i></i> action, rather than <i></i>忒o<i></i> actions. Suppose you want to open a site called &#60;https://news.ycombinator.com&#62; and you type in the url and hit Enter(like `cd hacker-news`). Then do you need to type in `open` to read?<p>Hope one day we may fix it.
======
nayefc
You can add an alias in bash to fix this. Or type dir && ls. Your assumption
is wrong. We don't "type ls after cd". Maybe a lot of times, but definitely
not most of the times. I memorize my directories from the first time I'm in
that I barely need to type ls.

~~~
jiyinyiyong
Still feeling strange that someone remembers all files and pathes. (Or maybe
the habbits in China is a bit different. Even I use Bash everyday, I still
want to read file list every time I enter a directory.)

~~~
nayefc
I usually cd into the main directory I want to be in and then if I ever want
to edit a file, simply typing emacs then tab for bash for auto-completion does
the trick.

But again, just use a bash alias :) What's the problem with that?

------
maerF0x0
scripting is your friend:

$ function newcd(){ cd $1; ls;}

$ alias cd=newcd

$ cd ..

$ cd Desktop

EDIT: I had accidentally put a "$1" in the ls command, now removed.

~~~
jiyinyiyong
That's my solution right now. There's a bug I don't kown if you can grt rid of
it or not.

When I type `cd a\ dir`, it works, while `c a\ dir` fails. `$1` seems not to
cover the whole parameter. Can you fix this?

------
mmozeiko
Very often I don't want ls. I want cd X && make. Or cd X && svn up. Or
something similar.

~~~
jiyinyiyong
I think it doesn't metter if this command gives several lines more logs. It
doesn't do anything else that may break the faollowing command.

------
nayefc
Why does this sound like a marketing email/post to me?

------
iamtherockstar
Huh? Since when do you always use 'ls' after 'cd' - I can think of many times
that I don't need to do this, and it would annoy me if every time I called
'cd' it then printed out the directory listing as well.

The popular Unix mantra is "do one thing and do it well" - both these
commands, while definitely connected, are each "one thing" and they both
perform them very well.

~~~
jiyinyiyong
The philosophy of Unix convinced me at my first glance. But then found there
might be some problem in this case.

Just an example. People may say something offer three features, one plus one
and plus one, just like Unix does. But if we are going to explain 99, it is
faster to say 100 minus 1 rather than 90 plus 9.

`cd $1 && ls` is a larger command. It's also an easier one.

