cd in PowerShell to, cd plus ls

Question:

How I can write a function or alias a command in PowerShell so that cd can do two things:

  1. cd the given dir
  2. ls the dir content

EDIT:

What I need is this:

but instead of ccd I want to write cd. When I change the function name to cd (from ccd) it changes the directory, but does not list the items in it :(. Seems that my cd function is being overridden.

Answer:

You mean something like this?

I see that you actually want to change the built-in cd alias. To do that, you would need to remove the existing one then create the new one:

Source:

cd in PowerShell to, cd plus ls by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply