Create and enter directory with one command
I often use these two command successively:
$ mkdir folder
$ cd folder
To combine these in one command (mde
, make directory and enter) and make it constant, use the following command:
$ echo 'mde () { mkdir -p "$@" && cd "$@"; }' >> ~/.bashrc
Change .bashrc
with the config file of the shell your use. To reload the config, use:
$ . ~/.bashrc
Now you can use it like:
$ mde folder
Note Some shells define their own aliases. E.g. defines md
as an alias for mkdir -p
. In order to check if the command already has been taken, use which <command>
.
Written by Auke Willem Oosterhoff
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Related Tags
#shell
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#