I have found myself keep doing cd some_dir
quickly followed by ls
for quite some time now, and have been trying to write a bash alias to let me do this, such as:
alas cd="cd $@; ls";
Problem with this is you can't have an input argument in the middle of an alias (correct me if I'm wrong).
I've also tried defining my own shell function as suggested by this page:
cd() { cd "$@"; ls; }
But the problem with this one is if I try to use it like so:
cd Documents
the shell exits with [Process completed]
, rendering the shell useless... So how should I get around this?
alas
as a builtin.cdl
" or something else. Otherwise, you'll get into this habit. Worse: you could encounter times when you wouldn't want to ls. e.g., when handling a remote filesystem, it may be slow. When runningmake
, a script mightcd
a lot, and there's no point in slowing the script down. Simply, out of habit, you're best off trying to not conflict with widely deployed native commands you know about.