I frequently run the ls
command after running the cd
command. How can I create an alias (like cs
) for this operation?
Ubuntu – How to create an alias for cd and ls
aliasbashcommand line
aliasbashcommand line
I frequently run the ls
command after running the cd
command. How can I create an alias (like cs
) for this operation?
Best Answer
From Bash Tips and Tricks: 'cd' with style:
As @geirha corretly notes, the above function will fail if you try to switch to a directory with a space in its name:
You should instead use the following function:
Once you add that code to your
~/.bashrc
, you should be able to do this: