function cs() { if [ $# -eq 0 ]; then cd && ls else cd "$*" && ls fi } alias cd='cs'Easy. All it does is create a function cs() that will call the standard cd command with any arguments passed into it. Once the directory is changed, it will list the directory contents with an ls. The default behavior of cd is replaced using alias.
Update 05-01-2012: I noticed that this disables the default behavior of cd going to the home directory when no arguments are passed. There is probably a much more clever way to handle this, but the above code now handles that.
Resources:
Ubuntu Forums Post: http://ubuntuforums.org/showthread.php?t=1708802
Thanks for posting this - exactly what I was looking for!
ReplyDeleteThis is exactly what I was looking for. Thanks!
ReplyDelete