Let's say I have the following command:
mkdir directory && cd directory
I normally do this a lot during the day so I'm wondering if there is a simpler shorter way of doing this.
Does anybody know?
Let's say I have the following command:
mkdir directory && cd directory
I normally do this a lot during the day so I'm wondering if there is a simpler shorter way of doing this.
Does anybody know?
Put the following code in your ~/.bashrc or ~/.zshrc :
mkcd () {
mkdir "$1"
cd "$1"
}
Then in your shell, enter the following command mkcd foo. As you can see, this function need one argument which are the name of the directory.
you can call last argument by &_
mkdir directory && cd $_
this is result
system:/tmp # mkdir directory && cd $_
system:/tmp/directory #