- Published on
Automatically CD into a directory after Mkdir
- Authors
- Name
- Yair Mark
- @yairmark
When I find myself repeating the same set of commands in the shell I try to see if there is some way to alias it to avoid future repetition.
One common pattern is:
mkdir someDir
cd someDir
So I added a zsh/bash function to my .zshrc
to do this automatically as below:
function mkdir(){
command mkdir -p "$1" && cd "$1";
}
The above simply becomes:
mkdir someDir
Note:
builtin
does not work formkdir
the way it does withcd
instead you need to usecommand
as above