DEV Community

Discussion on: Minimizing Keystrokes, Maximizing Productivity  -  Bash Scripting

Collapse
 
goodevilgenius profile image
Dan Jones • Edited

Your cd function could be greatly simplified:

function cd() {
    builtin cd "$@"
    ls
}

cd with no arguments already goes to the home folder. "$@" passes all arguments passed to the function exactly as they were passed. If there were none passed, it passes nothing.

Collapse
 
akshansh2000 profile image
Akshansh Bhanjana

Ahh, this looks great. It was a simple solution, really (should've been obvious to me). Perhaps, I spent a little too time thinking :P

Made the changes. Thanks!